Reputation: 245
Trying to write a loop that takes data from a read-only Excel file, and pastes it into a separate Excel file. Everything in this code works great, other than it is not saving the file. Here is all my code:
#q::
savefile := "path"
loop
{
xl := ComObjActive("Excel.Application") ;Create handle
xl.Visible := true
xl.Range("A:I").Copy ;copy cell to clipboard
Sleep, 500
xl_Workbook := xl.Workbooks.Open("path") ;Open output workbook
Sleep, 500
xl.Range("A:I").Select ;Ensure proper area of worksheet is being used
Sleep, 500
xl.ActiveSheet.Paste ;Paste into output
Sleep, 3000
xl.ActiveWorkbook.SaveAs(savefile)
Sleep, 3500
xl.ActiveWorkbook.Close() ;Close workbook
Sleep, 60000
} return
I have tried using just:
xl.ActiveWorkbook.Save()
but still, no luck.
Upvotes: 0
Views: 429
Reputation: 245
Re-started computer and the code worked... very odd, but it works!
Upvotes: 0