Jump to content

_Excel_RangeRead Loop Error


Recommended Posts

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

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

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.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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)      ;

 

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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

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

statement.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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. 

 

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

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

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

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

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

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. :/

You miss 100% of the shots you don't take. -Wayne Gretzky -Michael Scott

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...