Link to home
Start Free TrialLog in
Avatar of beatified
beatifiedFlag for United States of America

asked on

AutoHotKey not creating expected MsgBox Output.

So I am creating an AHK Script in Windows XP with Excel 2010 and am having problems using the script in that environment.

The Excel file was originally created with Excel 2016. I'm not sure what I'm doing right but in the end all I get is my yes no and cancel buttons not the %Output%.

I don't know if maybe I am running into some compatibility issues between version or what?

Here's the code...
#Warn,UseUnsetLocal
#NoEnv
#SingleInstance Force
SetBatchLines,-1

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

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)
    Continue ; ignore first row
  CurrentRow:=A_Index
  Loop,%NumberColumns%
  {
    If (A_Index=1 or A_Index=8)
      Continue ; ignore columns A and H
    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), %Output%
IfMsgBox Yes
    MsgBox You pressed Yes.
IfMsgBox No
	MsgBox You pressed No.
else
    MsgBox You pressed Cancel.
ExitApp

Open in new window

Attached are pictures of what happens. From what I understand it should be displaying %Output%.
I'm sure this is an easy one but I'm totally missing it.

Thanks, Stuart
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Hi Stuart,
Attachments missing. Regards, Joe
Avatar of beatified

ASKER

Oops...
PathtoC.bmp
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That explains why it was closing the MsgBox on its own. :)
Yep! :) The last param is the Timeout in seconds...should be a number...I have no idea what it does with a value like what's in your Output variable, but based on your comment, sounds as if it assigns some value to it...and closes the box accordingly.