Hello everyone,
I am using AHK with Excel to copy data and paste them in another program.
But since I had my Excel upgraded (not really had the choice) from 2010 version to 2016, my script does not work anymore.
Is this something that can just be changed in the .ahk file?
I am not a super user, the script was created by someone else.
Hope someone could help. Thanks a lot.
Excel upgrade 2010 to 2016 Topic is solved
Re: Excel upgrade 2010 to 2016
Are you free to paste the script?
Regards,
burque505
Regards,
burque505
Re: Excel upgrade 2010 to 2016
Hi burque505,
Thanks for your reply.
Yes, here it is:
SetKeyDelay, 80
WinWait, Microsoft Excel - Credit Creator,
IfWinNotActive, Microsoft Excel - Credit Creator, , WinActivate, Microsoft Excel - Credit Creator,
WinWaitActive, Microsoft Excel - Credit Creator,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Loop
{
Send, {CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
If clipboard = End
Break
Else
{
Order = %Clipboard%
}
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Material = %Clipboard%
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Description = %Clipboard%
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Amount = %Clipboard%
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Reason = %Clipboard%
WinWait, SAP Easy Access,
IfWinNotActive, SAP Easy Access, , WinActivate, SAP Easy Access,
WinWaitActive, SAP Easy Access,
FileRead, ORIGSCRIPT, %A_Desktop%\Geneva Project\Credit Creator\CC1.vbs
StringReplace, NEWSCRIPT1, ORIGSCRIPT, ORDERREPLACE, %Order%, All
FileDelete, %A_Desktop%\Geneva Project\Credit Creator\CC2.vbs
FileAppend, %NEWSCRIPT1%, %A_Desktop%\Geneva Project\Credit Creator\CC2.vbs
Runwait, %A_Desktop%\Geneva Project\Credit Creator\CC2.vbs
Loop
{
IfWinNotExist, Create Credit
{
Sleep, 1000
Send, {ENTER}
}
Else
{
Break
}
}
FileRead, ORIGSCRIPT, %A_Desktop%\Geneva Project\Credit Creator\CC3.vbs
StringReplace, NEWSCRIPT1, ORIGSCRIPT, MATERIALREPLACE, %Material%, All
StringReplace, NEWSCRIPT2, NEWSCRIPT1, DESCRIPTIONREPLACE, %Description%, All
StringReplace, NEWSCRIPT3, NEWSCRIPT2, AMOUNTREPLACE, %Amount%, All
StringReplace, NEWSCRIPT4, NEWSCRIPT3, REASONREPLACE, %Reason%, All
FileDelete, %A_Desktop%\Geneva Project\Credit Creator\CC4.vbs
FileAppend, %NEWSCRIPT4%, %A_Desktop%\Geneva Project\Credit Creator\CC4.vbs
Runwait, %A_Desktop%\Geneva Project\Credit Creator\CC4.vbs
Loop
{
IfWinNotExist, Display Sales Order
{
Sleep, 1000
}
Else
{
Sleep, 500
Send, {SHIFTDOWN}{END}{SHIFTUP}
Sleep, 300
Send, ^c
Send, {F3}
Sleep, 500
Break
}
}
WinWait, Microsoft Excel - Credit Creator,
IfWinNotActive, Microsoft Excel - Credit Creator, , WinActivate, Microsoft Excel - Credit Creator,
WinWaitActive, Microsoft Excel - Credit Creator,
Sleep, 500
Send, {RIGHT}^v
Send, {DOWN}{HOME}
Sleep, 300
}
MsgBox, All Credits have been created
Return
Thanks for your reply.
Yes, here it is:
SetKeyDelay, 80
WinWait, Microsoft Excel - Credit Creator,
IfWinNotActive, Microsoft Excel - Credit Creator, , WinActivate, Microsoft Excel - Credit Creator,
WinWaitActive, Microsoft Excel - Credit Creator,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Loop
{
Send, {CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
If clipboard = End
Break
Else
{
Order = %Clipboard%
}
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Material = %Clipboard%
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Description = %Clipboard%
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Amount = %Clipboard%
Send, {RIGHT}{CTRLDOWN}c{CTRLUP}
StringReplace, ClipBoard, Clipboard, `r`n, , All
Reason = %Clipboard%
WinWait, SAP Easy Access,
IfWinNotActive, SAP Easy Access, , WinActivate, SAP Easy Access,
WinWaitActive, SAP Easy Access,
FileRead, ORIGSCRIPT, %A_Desktop%\Geneva Project\Credit Creator\CC1.vbs
StringReplace, NEWSCRIPT1, ORIGSCRIPT, ORDERREPLACE, %Order%, All
FileDelete, %A_Desktop%\Geneva Project\Credit Creator\CC2.vbs
FileAppend, %NEWSCRIPT1%, %A_Desktop%\Geneva Project\Credit Creator\CC2.vbs
Runwait, %A_Desktop%\Geneva Project\Credit Creator\CC2.vbs
Loop
{
IfWinNotExist, Create Credit
{
Sleep, 1000
Send, {ENTER}
}
Else
{
Break
}
}
FileRead, ORIGSCRIPT, %A_Desktop%\Geneva Project\Credit Creator\CC3.vbs
StringReplace, NEWSCRIPT1, ORIGSCRIPT, MATERIALREPLACE, %Material%, All
StringReplace, NEWSCRIPT2, NEWSCRIPT1, DESCRIPTIONREPLACE, %Description%, All
StringReplace, NEWSCRIPT3, NEWSCRIPT2, AMOUNTREPLACE, %Amount%, All
StringReplace, NEWSCRIPT4, NEWSCRIPT3, REASONREPLACE, %Reason%, All
FileDelete, %A_Desktop%\Geneva Project\Credit Creator\CC4.vbs
FileAppend, %NEWSCRIPT4%, %A_Desktop%\Geneva Project\Credit Creator\CC4.vbs
Runwait, %A_Desktop%\Geneva Project\Credit Creator\CC4.vbs
Loop
{
IfWinNotExist, Display Sales Order
{
Sleep, 1000
}
Else
{
Sleep, 500
Send, {SHIFTDOWN}{END}{SHIFTUP}
Sleep, 300
Send, ^c
Send, {F3}
Sleep, 500
Break
}
}
WinWait, Microsoft Excel - Credit Creator,
IfWinNotActive, Microsoft Excel - Credit Creator, , WinActivate, Microsoft Excel - Credit Creator,
WinWaitActive, Microsoft Excel - Credit Creator,
Sleep, 500
Send, {RIGHT}^v
Send, {DOWN}{HOME}
Sleep, 300
}
MsgBox, All Credits have been created
Return
Re: Excel upgrade 2010 to 2016
In general, automating Excel would probably be more reliable through its COM interface, but that would require a re-write of your script.
Anyway, let's see what can be done with this script. The first thing I would check is the window title of Excel. Your script depends on a Excel window with the exact title Microsoft Excel - Credit Creator , for example here, already in the second line: If the title you get now, in Excel 2016, is for example Microsoft Excel 2016 - Credit Creator, then it will wait forever. So, right-click the script's icon in the systray, start 'Window Spy' and determine the window title you need by clicking the Excel window when you have the 'Credit Creator" open. The first row will give you the wintitle - copy and paste it to your script, replacing all instances of the old title. Perhaps, that is all you need to do... but before you change something, let's keep a backup of the original script (well, it is still in your post above, but anyway)
Anyway, let's see what can be done with this script. The first thing I would check is the window title of Excel. Your script depends on a Excel window with the exact title Microsoft Excel - Credit Creator , for example here, already in the second line:
Code: Select all
WinWait, Microsoft Excel - Credit Creator
Re: Excel upgrade 2010 to 2016
Hello gregster,
Thank you for your help. I thought this was just the file name to change.
So I opened windows SPY and I see on the first field "Window Tile, Class and Process":
Credit Creator - Excel
ahk_class XLMAIN
ahk_exe EXCEL.EXE
I have replaced all the Microsoft Excel - Credit Creator by Credit Creator - Excel, but the script still running running without doing anything.
Thank you for your help. I thought this was just the file name to change.
So I opened windows SPY and I see on the first field "Window Tile, Class and Process":
Credit Creator - Excel
ahk_class XLMAIN
ahk_exe EXCEL.EXE
I have replaced all the Microsoft Excel - Credit Creator by Credit Creator - Excel, but the script still running running without doing anything.
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: Excel upgrade 2010 to 2016
I looked at your code, and saw this:
IfWinNotActive, Microsoft Excel - Credit Creator, , WinActivate, Microsoft Excel - Credit Creator,
Do you have this on one line ?
If so, please change it to:
Does this pop up your excel file now ?
IfWinNotActive, Microsoft Excel - Credit Creator, , WinActivate, Microsoft Excel - Credit Creator,
Do you have this on one line ?
If so, please change it to:
Code: Select all
IfWinNotActive, Credit Creator - Excel
WinActivate, Credit Creator - Excel
Re: Excel upgrade 2010 to 2016
Actually, that should be ok, WalkerOfTheDay - not ideal, but ok.
https://autohotkey.com/docs/commands/WinActive.htm :
If the script isn't really doing anything, it might be worth a try to run the script as admin, though (of course, with the new window title)
https://autohotkey.com/docs/commands/WinActive.htm :
The problem is that probably something more changed in Excel 2016 compared to 2010, but without exactly knowing what the script should do and without having Excel 2016 (and assuming that it did work in Excel 2010), it won't be easy to isolate the problem - I don't see anything obvious, but I don't have Excel 2016, either. The original poster probably has to take a closer look at the code (and AHK in general) and try to debug it line by line.ExcludeTitle
Windows whose titles include this value will not be considered.
Note: Due to backward compatibility, IfWin[Not]Active interpret this parameter as a command if it exactly matches the name of a command. To work around this, use the WinActive function instead.
If the script isn't really doing anything, it might be worth a try to run the script as admin, though (of course, with the new window title)
Last edited by gregster on 26 Mar 2018, 09:01, edited 1 time in total.
Re: Excel upgrade 2010 to 2016
Thanks walker. Tried it, but it is still not working.
In fact I use to have my excel file open and it should go directly in it automatically.
So, tried this one:
SetKeyDelay, 80
WinWait, Credit Creator - Excel,
IfWinNotActive, Credit Creator - Excel,
WinActivate, Credit Creator - Excel,
WinWaitActive, Credit Creator - Excel,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Loop
and also this:
SetKeyDelay, 80
WinWait, Credit Creator - Excel,
IfWinNotActive, Credit Creator - Excel, , WinActivate, Credit Creator - Excel,
WinWaitActive, Credit Creator - Excel,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Loop
nothing is working unfortunately.
In fact I use to have my excel file open and it should go directly in it automatically.
So, tried this one:
SetKeyDelay, 80
WinWait, Credit Creator - Excel,
IfWinNotActive, Credit Creator - Excel,
WinActivate, Credit Creator - Excel,
WinWaitActive, Credit Creator - Excel,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Loop
and also this:
SetKeyDelay, 80
WinWait, Credit Creator - Excel,
IfWinNotActive, Credit Creator - Excel, , WinActivate, Credit Creator - Excel,
WinWaitActive, Credit Creator - Excel,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Loop
nothing is working unfortunately.
Re: Excel upgrade 2010 to 2016
try to run the script as admin
Is the script snippet doing anything when you have Excel open?
Is the script snippet
Code: Select all
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
- WalkerOfTheDay
- Posts: 710
- Joined: 24 Mar 2016, 03:01
Re: Excel upgrade 2010 to 2016
Well, this part you posted works in my version of excel 2016.
What do you see when you double-click the script symbol in your taskbar ?
Code: Select all
SetKeyDelay, 80
WinWait, Credit Creator - Excel,
IfWinNotActive, Credit Creator - Excel,
WinActivate, Credit Creator - Excel,
WinWaitActive, Credit Creator - Excel,
Sleep, 500
Send, {CTRLDOWN}f{CTRLUP}
Sleep, 500
Send, Order{ENTER}
Sleep,500
Send, {ESC}
Sleep, 500
Send, {DOWN}
Sleep, 300
Re: Excel upgrade 2010 to 2016
It works!
Do not know how, but I've removed some of the green button application from the old file, add a new one, and it works. Still have some little issues on the "clipboard copy/paste" but this should not be a problem to resolve.
THANK YOU SO MUCH for your help and support guys.
Have a great day/evening
Do not know how, but I've removed some of the green button application from the old file, add a new one, and it works. Still have some little issues on the "clipboard copy/paste" but this should not be a problem to resolve.
THANK YOU SO MUCH for your help and support guys.
Have a great day/evening
Who is online
Users browsing this forum: balawi28, Bing [Bot], Google [Bot], moltenchees and 266 guests