Jump to content
SkysLastChance

_Excel_RangeRead Loop Error

Recommended Posts

SkysLastChance

I am not sure why I am getting the this error on my second pass of the code.

1 - $oWorkbook is not an object or not a workbook object

Any help or advice on my code appreciated. 

#include <Excel.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

Global $sExcelFile1 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)")
Global $sExcelFile2 = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)")
Global $vRow = 2

If FileExists($sExcelFile2) Then
   Global $oExcel2 = _Excel_Open ()
    $oExcel2 = _Excel_BookOpen($oExcel2,$sExcelFile2)
EndIF

If FileExists($sExcelFile1) Then
   Global $oExcel1 = _Excel_Open ()
    $oExcel1 = _Excel_BookOpen($oExcel1,$sExcelFile1,Default,Default,"2007")
EndIF


$oRead = _Excel_RangeRead ($oExcel2,"Untitled","A2",3)
$oFind = _Excel_RangeFind ($oExcel1,$oRead,"E4:FD92",Default,$xlWhole)
$Clip = _ArrayToClip($oFind,"",0,0,"",2,2)


Send("{ScrollLock Off}")
$hWnd = WinWait("[CLASS:XLMAIN]")
ControlSend($hWnd, "", "", ("^g"))
WinWait("[CLASS:bosa_sdm_XL9]") ; Go To
ControlSend($hWnd, "", "", ("^v"))
ControlSend($hWnd, "", "", ("{Enter}"))
ControlSend($hWnD, "", "", "{Down " & $vRow & "}")

Do

$oTime  = _Excel_RangeRead ($oExcel2,"Untitled","B2",3)

If @error Then Exit MsgBox(0, "Error", "Error" & @CRLF & "@error = " & @error & ", @extended = " & @extended)


MsgBox(0,"Test",$oTime)

IF $oTime = "7:10:00 AM" Then
   $oCalls1 = _Excel_RangeRead ($oExcel2,Default,"C" & $vRow,3)
   $oCalls2 = _Excel_RangeRead ($oExcel2,Default,"D" & $vRow,3)
   ControlSend($hWnd, "", "", $oCalls1)
   ControlSend($hWnd, "", "", ("{RIGHT}"))
   ControlSend($hWnd, "", "", $oCalls2)
   $vRow = $vRow + 1
   ContinueLoop
Else
   $vRow = $vRow + 1

EndIf

Until $vRow = 4

1.xlsm

2.xlsx


Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites
water

Maybe because you use variables $oExcel1 / $oExcel2 to hold the application AND the workbook object.
Example:

If FileExists($sExcelFile2) Then
   Global $oExcel2 = _Excel_Open ()
    $oExcel2 = _Excel_BookOpen($oExcel2,$sExcelFile2)
EndIF

BTW: There is no need to call _Excel_Open two times. Call _Excel_Open after starting the script once and use the returned application object to open both workbooks.

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
SkysLastChance

Thank you!

This is how I changed it. I hope this is what you meant.

#include <Excel.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

Global $vRow = 2

Local $oExcel = _Excel_Open()
Local $sWorkbookx = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)")
Local $oWorkbookx = _Excel_BookOpen($oExcel, $sWorkbookx)
Local $sWorkbookm = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)")
Local $oWorkbookm = _Excel_BookOpen($oExcel, $sWorkbookm,Default,Default,"2007")



$oRead = _Excel_RangeRead ($oWorkbookx,"Untitled","A2",3)
$oFind = _Excel_RangeFind ($oWorkbookm,$oRead,"E4:FD92",Default,$xlWhole)
$Clip = _ArrayToClip($oFind,"",0,0,"",2,2)

Send("{ScrollLock Off}")

Local $hWnd = WinWait("[CLASS:XLMAIN]")
ControlSend($hWnd, "", "", ("^g"))
WinWait("[CLASS:bosa_sdm_XL9]") ; Go To
ControlSend($hWnd, "", "", ("^v"))
ControlSend($hWnd, "", "", ("{Enter}"))
ControlSend($hWnD, "", "", "{Down " & $vRow & "}")

Do

$oTime = _Excel_RangeRead($oWorkbookx,Default,"B2",3)

MsgBox(0,"Test",$oTime)

IF $oTime = "7:10:00 AM" Then
   $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vRow,3)
   $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vRow,3)
   ControlSend($hWnd, "", "", ("^v"))
   ControlSend($hWnd, "", "", ("{Down}"))

   ;ControlSend($hWnd, "", "", $oCalls1)      ;
   ;ControlSend($hWnd, "", "", ("{RIGHT}"))   ;
   ;ControlSend($hWnd, "", "", $oCalls2)      ;
   $vRow = $vRow + 1
   ContinueLoop
Else
   $vRow = $vRow + 1

EndIf

Until $vRow = 4

The script works fine now until I add. 

$oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vRow,3)
  $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vRow,3)
  
  ControlSend($hWnd, "", "", $oCalls1)      ;
  ControlSend($hWnd, "", "", ("{RIGHT}"))   ;
  ControlSend($hWnd, "", "", $oCalls2)      ;

 


Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites
water

What do you mean by "The script works fine now until I add."?
Please describe as detailed as possible what you expect and what you get. Any error messages etc. ...?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

Do you not specify a ControlID on purpose?
If you specify the ControlID you can drop the

ControlSend($hWnd, "", "", ("{RIGHT}"))

statement.

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
SkysLastChance

Sorry for not being more clear. My poor code dose not help either.

So, as you probally expected the code was doing exactly what it was supposed to do. It was just not working how I wanted it to. LOL 

Thank you for your patients @Water

I fixed this as well. 

ControlSend($hWnd, "", "EXCEL72", $oCalls1)
   ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
   ControlSend($hWnd, "", "EXCEL72", $oCalls2)

I am starting to think this is not even going to work for what I want it to do.  :/

I am going to keep playing around with it though. 

 


Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites
SkysLastChance

I have it working they way I want now. 

I was just wondering is there a way to make this faster?

#include <Excel.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

Global $hWnd,$oExcel,$sWorkbookx,$oWorkbookx,$sWorkbookm,$oWorkbookm,$oExcelm,$oExcelx

Excel ()


AMSeven  ()
AMEight  ()
AMNine   ()
AMTen    ()
AMEleven ()
PMTwelve ()
PMOne    ()
PMTwo    ()
PMThree  ()
PMFour   ()
PMFive   ()
PMSix    ()

Func Excel ()
   $oExcel = _Excel_Open()
   $sWorkbookx = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)")
   $oWorkbookx = _Excel_BookOpen($oExcel, $sWorkbookx)
   $sWorkbookm = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)")
   $oWorkbookm = _Excel_BookOpen($oExcel, $sWorkbookm,Default,Default,"2007")
   $oExcelm = _Excel_BookAttach($oWorkbookm)
   $oExcelx = _Excel_BookAttach($oWorkbookx)
   Local $oRead = _Excel_RangeRead ($oWorkbookx,"Untitled","A2",3)
   Local $oFind = _Excel_RangeFind ($oWorkbookm,$oRead,"E4:FD92",Default,$xlWhole)
   Local $Clip = _ArrayToClip($oFind,"",0,0,"",2,2)
   Send("{ScrollLock Off}")
   $hWnd = WinWait("[CLASS:XLMAIN]")
   ControlSend($hWnd, "", "EXCEL72", ("^g"))
   WinWait("[CLASS:bosa_sdm_XL9]") ; Go To
   ControlSend($hWnd, "", "", ("^v"))
   ControlSend($hWnd, "", "", ("{Enter}"))
   ControlSend($hWnD, "", "", "{Down 2}")
EndFunc

Func AMSeven ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "7:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMEight ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "8:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMNine ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "9:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMTen ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "10:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMEleven ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "11:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func PMTwelve ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "12:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc






Func PMOne ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "1:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMTwo ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "2:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMThree ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "3:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMFour ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "4:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMFive ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "5:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMSix ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "6:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites
SkysLastChance
Spoiler
#include <Excel.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>

Global $hWnd,$oExcel,$sWorkbookx,$oWorkbookx,$sWorkbookm,$oWorkbookm,$oExcelm,$oExcelx

Excel ()


AMSeven  ()
AMEight  ()
AMNine   ()
AMTen    ()
AMEleven ()
PMTwelve ()
PMOne    ()
PMTwo    ()
PMThree  ()
PMFour   ()
PMFive   ()
PMSix    ()

Func Excel ()
   $oExcel = _Excel_Open()
   $sWorkbookx = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "Excel Sheet (*.xlsx;*.xls)|All (*.*)")
   $oWorkbookx = _Excel_BookOpen($oExcel, $sWorkbookx)
   $sWorkbookm = FileOpenDialog("Choose/Create Excel File", @ScriptDir, "(*.xlsm)")
   $oWorkbookm = _Excel_BookOpen($oExcel, $sWorkbookm,Default,Default,"2007")
   $oExcelm = _Excel_BookAttach($oWorkbookm)
   $oExcelx = _Excel_BookAttach($oWorkbookx)
   Local $oRead = _Excel_RangeRead ($oWorkbookx,"Untitled","A2",3)
   Local $oFind = _Excel_RangeFind ($oWorkbookm,$oRead,"E4:FD92",Default,$xlWhole)
   Local $Clip = _ArrayToClip($oFind,"",0,0,"",2,2)
   Send("{ScrollLock Off}")
   $hWnd = WinWait("[CLASS:XLMAIN]")
   ControlSend($hWnd, "", "EXCEL72", ("^g"))
   WinWait("[CLASS:bosa_sdm_XL9]") ; Go To
   ControlSend($hWnd, "", "", ("^v"))
   ControlSend($hWnd, "", "", ("{Enter}"))
   ControlSend($hWnD, "", "", "{Down 2}")
EndFunc

Func AMSeven ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "7:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMEight ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "8:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMNine ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "9:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMTen ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "10:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func AMEleven ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "11:00:00 AM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

Func PMTwelve ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "12:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc






Func PMOne ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "1:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMTwo ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "2:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMThree ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "3:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMFour ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "4:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMFive ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "5:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc


Func PMSix ()

Local $vCalls = 2
Local $vTime  = 2
Local $vCount = 0
Local $vTrigger = 0

Do

Local $oTime = _Excel_RangeRead($oWorkbookx,Default,"B" & $vTime,3)

IF $oTime <> "6:00:00 PM" Then
      $vTime  = $vTime  + 1
      $vCount = $vCount + 1
      $vCalls = $vCalls + 1

Else

Local $oCalls1 = _Excel_RangeRead ($oWorkbookx,Default,"C" & $vCalls,3)
Local $oCalls2 = _Excel_RangeRead ($oWorkbookx,Default,"D" & $vCalls,3)
    ControlSend($hWnd, "", "EXCEL72", $oCalls1)
    ControlSend($hWnd, "", "EXCEL72", ("{Right}"))
    ControlSend($hWnd, "", "EXCEL72", $oCalls2)
    ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
    ControlSend($hWnd, "", "EXCEL72", ("{Left}"))
 $vCalls = $vCalls + 1
 $vTime  = $vTime  + 1
   ExitLoop
EndIF

Until $vCount = 14

If $vCount = 14 Then
   ControlSend($hWnd, "", "EXCEL72", ("{Down}"))
EndIF

EndFunc

 

 

The only date this code will find is 6/19/2017 (In A2 of Sheet 2.) This code does not work if I have a different date in A2. If I put 6/26/2017 it will not find anything. 

I figured it has to be something to do with the way it is formated in excel, However from what I can tell they are formated the same. 

When I read the cells they (6/19/17) and (6/26/17) both on sheet 2.  They display the same information.

When I _Excel_RangeFind it works when I have 6/19/2017 in A2. But if I switch to any other date. It will not find anything. 

Everything needed to test script is in my original post.

I could really use some help on this. 

 

Edited by SkysLastChance
Added Code

Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites
SkysLastChance

Go figure I solved my problem right after I post. 

I fixed it by copy and pasting the dates again and redoing the merge and center for all of them.

I still have no idea why it wasent working though. :/


Life's simple. You make choices and you don't look back.

Share this post


Link to post
Share on other sites
water

Maybe you stored the dates as strings and by using copy & paste Excel interpreted them as dates?
Nevermind: Glad the problem could be solved!

  • Like 1

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • nooneclose
      By nooneclose
      My program has to first search for names in Column D that do not match up with column C. I got that search to work using arrays. It was slow and I could not figure out how to delete them so I just manually put coded the names that do not belong. I found their cell location but I do not know how to store that location and delete it.
      This is what I have so far.
      Local $NameToDelete1[6]  = _Excel_RangeFind($OpenWorkbook, "Smith, Bill") _ArrayDisplay($NameToDelete1, "Excel UDF: _Excel_RangeFind Example 1", "", 0, "|", "Sheet|Name|Cell|Value|Formula|Comment") _Excel_RangeDelete($OpenWorkbook.ActiveSheet, $NameToDelete1[2], $xlShiftUp)  
      Please help, I wanted to have this program done yesterday but I did not see this problem until yesterday. 
    • nooneclose
      By nooneclose
      I need to perform a subtotal in excel and I would like to automate this process using Autoit if possible like always any and all help will be greatly appreciated. 
      I can not find a good example but the two from Microsoft. Here is one of the two from msdn.microsoft.com/en-us/vba/excel-vba/articles/range-subtotal-method-excel
      I do not really understand how to translate this into AutoIt, but I gave it a try and here is what I have.
      $OpenRange      = "A1:E200" $xlSum          = -4157 $Added_Array[2] = [2, 3] $OpenRange.Subtotal("B1", $xlSum, $Added_Array, True, False, True) I just need to perform a subtotal on a range based on a header called department, and then perform a sum on the results.
    • nooneclose
      By nooneclose
      How to use _Excel_RangeSort to sort my excel file by three different headers Column A1, B1, and C1 have headers on which I want to sort by. The headers on which I want to sort are department, employee type, and name.
      I still really new to AutoIt so I do not actually know how to properly start this line or lines of code, to be honest. The example code is the best I can do.
      _Excel_RangeSort($OpenWorkbook, Default, "A1:C1", "1:1", $xlDescending, Default, $xlYes, Default, $xlSortRows) I just need to sort by those three headers in that order of department, employee type, and name, plus in descending order.
       
      any and all help would be greatly appreciated.  Thank you!
    • Daniza
      By Daniza
      It works fine on my Excel 2007, but after I Emailed My Area Manager he told me after he Enable Macro Security nothing happen's, can someone test this to run on Excel 2016? My AM can't provide me more information 

      Thank You in Advance,
      Please see attachment.
      <snip>
    • tuffgong
      By tuffgong
      Good morning. I have a system I am trying to automate that works like this: user fills a column in an Excel spreadsheet with values they would like printed and saves it to a folder on their desktop, they start the script and it formats their data into a text file (adding a prefix) and sends the text file as a .bch file where it needs to go. This is working:
      #include <Array.au3> #include <Excel.au3> #include <File.au3> #include <MsgBoxConstants.au3> Global $sSTCArray Global $sFilename = @DesktopDir & "\Labels\print.txt" Global $sWorkbook = @DesktopDir & "\Labels\Labels.xlsx" Global $oExcel = _Excel_Open(False,False,False,False,True) barcodePrint() Func barcodePrint() $Read = _Excel_BookOpen($oExcel, $sWorkbook, True, False, Default, Default, Default) FileOpen($sFilename, $FO_OVERWRITE) ;Global $oWorkbook = _Excel_BookAttach($oExcel) Global $sSTCArray = _Excel_RangeRead($Read) For $i = 0 to UBound($sSTCArray, 1) - 1 FileWriteLine($sFilename, "!StaticShelving1x3_ZPL," & $sSTCArray[$i]) Next _Excel_Close($oExcel) FileMove($sFilename, "***file path***\print.bch") EndFunc However, it only works if the user first formats the spreadsheet to text. I want to automate that. From what I have read it appears AutoIt does not like formatting cells that already have values. True? Can I pull the values from an un-formatted (default GENERAL format) spreadsheet and go straight to my text file? I have also considered opening a second spreadsheet, formatting it, and copying the values over. Like this:
        
      Global $sPrefix Global $oPath Global $sSTCArray Global $sFilename = @DesktopDir & "\Labels\print.txt" Global $sWorkbook = @DesktopDir & "\Labels\Labels.xlsx" Global $oExcel = _Excel_Open(False,False,False,False,True) Global $aArray Global $bExcel _Excel_BookNew($bExcel) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $aArray = IniReadSection("***File path***\barcode.ini", "stc/rvt/mgm") $sPrefix = $aArray[1][1] $oPath = $aArray[2][1] barcodePrint() EndSwitch WEnd Func barcodePrint() $oWorkbook = _Excel_BookOpen($bExcel, @DesktopDir & "\Labels\print.xlsx") $oWorkbook.ActiveSheet.Columns("A").NumberFormat = "@" Local $Read = _Excel_BookOpen($oExcel, $sWorkbook, True, False, Default, Default, Default) $oCopy = _Excel_RangeRead($sWorkbook) _Excel_RangeWrite($oWorkbook, Default, $oCopy) FileOpen($sFilename, $FO_OVERWRITE) $sSTCArray = _Excel_RangeRead($Read,"Default","Default",3) ;_ArrayDisplay($sSTCArray) For $i = 0 to UBound($sSTCArray, 1) - 1 FileWriteLine($sFilename, $sPrefix & $sSTCArray[$i]) Next _Excel_Close($oExcel) ;FileMove($sFilename, $oPath) Exit EndFunc This does not like the formatting of $oWorkbook: "Variable must be of type 'Object'".  Do I need this second sheet? If so, how can I format it? Is there a better way to get the Excel values into a .txt file? Any ideas would be appreciated. Thanks!
×