Residual Data when running AutoHotKey Script on Excel data????

beatified
beatified used Ask the Experts™
on
For some reason I run a AHK Script that calls an excel file and the returned data seems to be completely different and data that doesn't exist in the xlsx file. When I copy the data to a brand new xlsx file it seems to work properly. Is there residual data in the xlsx file?

Also I am trying to call a specific sheet in the work book and it doesn't seem to be working? As I see it this is the main problem as I don't believe the problem would exist if I called the sheet correctly.

#Warn,UseUnsetLocal
#NoEnv
#SingleInstance Force
SetBatchLines,-1

SourceFile:="C:\Documents and Settings\Administrator\Desktop\Working.xlsx"
DepNum:=14871
;InputBox, DepNum, Deposit Number, Enter the Deposit Number you would like to process
NumberColumns:=9
NumberRows:=30

Output:=""
ColumnLetters:=["A","B","C","D","E","F","G","H","I"]
oWorkbook:=ComObjGet(SourceFile)
oExcel.Sheets(DepNum).Select
ExcelCells:=Object()
Loop,%NumberRows%
{
  If (A_Index=1 or A_Index=2)
    Continue ; ignore first row
  CurrentRow:=A_Index
  Loop,%NumberColumns%
  {
    If (A_Index=1)
      Continue ; ignore column A
    If (A_Index=6)
      SetFormat,Float,6.2
    If (A_Index=7 or A_Index=9)
      SetFormat,Float,6.0
    CurrentColumn:=ColumnLetters[A_Index]
    CurrentCell:=CurrentColumn . CurrentRow
    ExcelCells[CurrentColumn,CurrentRow]:=oWorkbook.Worksheets(1).Range(CurrentCell).Value
    If (A_Index=2)
      Output:=Output . "10" . ExcelCells[CurrentColumn,CurrentRow] . " - "
    Else
      Output:=Output . ExcelCells[CurrentColumn,CurrentRow] . " - "
    If (A_Index=9)
      StringTrimRight,Output,Output,3
  }
  Output:=Output . "`n"
}
MsgBox, 3, Correct?, Is this the information You would like to process? (press Yes or No or Cancel to quit) `n%Output%
IfMsgBox Yes
    MsgBox You pressed Yes.
IfMsgBox No
	MsgBox You pressed No.
else
    MsgBox You pressed Cancel.
ExitApp

Open in new window


Working
Working.xlsx

Not Working
-Working.xlsx
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This was my solution.
   ExcelCells[CurrentColumn,CurrentRow]:=oWorkbook.Worksheets(1).Range(CurrentCell).Value

Open in new window


Needed to be.
   ExcelCells[CurrentColumn,CurrentRow]:=oWorkbook.Worksheets(DepNum).Range(CurrentCell).Value

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial