I need help with AHK + Excel COM = Excel Opens veeeeery slowly.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

I need help with AHK + Excel COM = Excel Opens veeeeery slowly.

04 Jul 2018, 11:36

I have been using AHK with Excel COM for a while already, Excel 2016 for some reason now Excel 2016 says 365 maybe the newest version is bound into 365, I have no idea in regards to this. But for some reason these 2 weeks my uncle has been reporting about excel not opening fast and he was right!

Symptoms:

Excel taking 10-15 sec to open a new book (book1)

If I immediately try to open excel again within 10-15 sec excel opens book2 then book1, no need to wait book1 to open first. weird

I quit my ahk script and excel opens normally again. (maybe I did some change to my script? I doubt it, haven't touched it since a while.

There was once I tried to open excel and book9 opened always instead of book1 everytime.

Script used:

excel_filename := "fer.client_searcher.xlsm - Excel" ;excel searcher name
IfWinExist, %excel_filename%
{
WinActivate, %excel_filename%
WinWaitActive, %excel_filename%,,2
newmatch_or_Search := newmatch
gosub, excel_handle_macro_paste
return
} else {
IfWinNotExist, %excel_filename%
file := "C:\Users\" A_UserName "\Google Drive\AHK\fer.client_searcher.xlsm"
Run, %file%
gosub, during_after_wait
newmatch_or_Search := newmatch
gosub, excel_handle_macro_paste
return
} } else {
excel_filename := "fer.searcher.xlsm - Excel" ;excel searcher name
IfWinExist, %excel_filename%
{
WinActivate, %excel_filename%
WinWaitActive, %excel_filename%,,2
newmatch_or_Search := Target
gosub, excel_handle_macro_paste
return
} else {
IfWinNotExist, %excel_filename%
file := "C:\Users\" A_UserName "\Google Drive\AHK\fer.searcher.xlsm"
Run, %file%
gosub, during_after_wait
newmatch_or_Search := Target
gosub, excel_handle_macro_paste
} } return

excel_handle_macro_paste:
Xl := Excel_Get() ;creates a handle to your currently active excel sheet
xlsfile := xl.ActiveWorkbook.name ;retrieves the name of the active workbook
xl.Run(xlsfile "!Box") ;run excel macro
Clipboard =
Clipboard := newmatch_or_search ;search for submit data or newmatch for extracted data from regex
ClipWait
Send, ^v{Enter}
return

during_after_wait:
WinWait, %excel_filename%
WinActivate, %excel_filename%
WinWaitActive, %excel_filename%,,2
return
This is just some code of the big script but this is what the main thing basically does with EXCEL COM

Xl := Excel_Get() ;creates a handle to your currently active excel sheet
xlsfile := xl.ActiveWorkbook.name ;retrieves the name of the active workbook
xl.Run(xlsfile "!Box") ;run excel macro+
Ok so this has worked for a long long time. Windows 10, Office 2016. Both have been updated but still remain on same versions. What could be the cause for this? I was even about to reinstall Windows 10!!! I'm glad I noticed my script was causing this problem.

PS: btw The only problem is Excel taking 10 seconds to open something, the rest ahk and excel works every time.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Beorn, Bing [Bot], cinematic6436, nacken012 and 125 guests