Jose-phil wrote:
Now to see if I can incorporate the 'save to USB' code ....
We simply need to incorporate
@flyingDman's code above without the line that closes Excel.
Code: Select all
#Requires AutoHotkey v1.1.33+
; Microsoft Excel - Book1.xlsx
SetTitleMatchMode 2
WinActivate, ahk_class XLMAIN
send ^s
sleep 1000 ; adjust as necessary
xl := ComObjActive("excel.application")
xl.activeWorkbook.SaveCopyAs("E:\" xl.activeWorkbook.name) ; E:\ or whatever path
return
Note: I added the "sleep" statement because Excel can't save to two places at the same time, so the script has to wait until the first save is finished before commencing the second one. If you get the following error:
- image.png (13.4 KiB) Viewed 1470 times
it means that your system is slower than mine, so just increase the value of the sleep. (1000 is 1000 milliseconds, or 1 second)
Note: If your flash drive uses a different letter than "E:", you will need to change the target location in the second-to-last line. Just change "E:\" to "F:\" or whatever the correct drive letter is. You can also add a path such as "F:\MyExcelFiles\". Be sure to leave the trailing
\ character in the path.
Note: Not all the code fits in the code window above, so you have to scroll down within the code window to see all of it. That is also what the "Select all" link is for - clicking it will select all the code in the code box and you can then copy and paste it into your editor.
Russ