I am trying to run Excel via AutoHotKey as every single tutorial suggests by using the COM object through this command ComObjCreate("Excel.Application")
. However, it does not get past this command as it says "invalid class string".
This is on Win 10 with the Office 365 Excel on it.
2 Answers
try ComObjCreate("Excel.Application")
Probably you have to run the script as administrator
Did you assign to a variable etc? Without more information, I can only say the following works on my system.
msexcel := ComObjCreate("Excel.Application")
wbk := msexcel.Workbooks.Add()
msexcel.Visible := true
>Exit code: 0 Time: 1.282
Note Excel may open minimized. You may need to look carefully to find the window.
It may be that Excel is not registered with com for some reason. Reinstalling may help.
Instead of reinstalling, another thing I have not had to do in years is to manually register an application.
Find the path to Excel. On my machine it is :
"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
Open the run dialog box then issue the command:
"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE" /regserver
Then try the above program again.
When I issued the command on my system Excel opened. Then I closed Excel.
-
Yes, the same exact code does not work for me for some reason, throws the "invalid class string". Very puzzling. Jun 7, 2020 at 3:23
-