0

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.

Here is the screenshot of the issue: enter image description here

1
try ComObjCreate("Excel.Application")

See Dealing with COM errors.

Probably you have to run the script as administrator

| improve this answer | |
  • It still does the same ran as administrator. – Vasily Hall Jun 7 at 18:50
0

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.

| improve this answer | |
  • Yes, the same exact code does not work for me for some reason, throws the "invalid class string". Very puzzling. – Vasily Hall Jun 7 at 3:23
  • Updated answer to register Excel with com. – Carl_M Jun 8 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.