Author Topic: Unable to create Excel Object  (Read 252 times)

0 Members and 1 Guest are viewing this topic.

Mikosalm

  • Mosquito
  • Posts: 5
Unable to create Excel Object
« on: September 26, 2019, 01:10:23 PM »
Hi Everyone,

I am having trouble creating an excel object. The below line works on all of our workstations except one in which it returns nil.

Code: [Select]
(setq xl (vlax-get-or-create-object "Excel.Application"))
Excel is installed on the computer and I can open the workbook manually. Anyone know how to correct this?

MP

  • Seagull
  • Posts: 17446
Re: Unable to create Excel Object
« Reply #1 on: September 26, 2019, 01:48:22 PM »
The specified progid is incorrect, like missing a version number. e.g. "Excel.Application.14".

See this thread.

Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Mikosalm

  • Mosquito
  • Posts: 5
Re: Unable to create Excel Object
« Reply #2 on: September 26, 2019, 02:11:44 PM »
Thanks for the response MP

The proid works without the version number on other similar workstations so I am not sure why it would be needed here.

Tried it anyways though and it still returns nil. Using Office 2016 so I tried "Excel.Application.16" as well as what you suggested.

MP

  • Seagull
  • Posts: 17446
Re: Unable to create Excel Object
« Reply #3 on: September 26, 2019, 02:35:03 PM »
Did you try the utility I referenced, e.g. (mapcar 'print (_FindProjIDs "*excel*")) and if so what was the result?
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Mikosalm

  • Mosquito
  • Posts: 5
Re: Unable to create Excel Object
« Reply #4 on: September 26, 2019, 03:53:23 PM »
Hey MP,

This was the returned result: "AdobePDFMakerX.ExcelSheetsDlg" ("AdobePDFMakerX.ExcelSheetsDlg")

MP

  • Seagull
  • Posts: 17446
Re: Unable to create Excel Object
« Reply #5 on: September 26, 2019, 03:57:43 PM »
Surely more than that was returned, especially if excel is installed as you say.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

jtoverka

  • Newt
  • Posts: 29
Re: Unable to create Excel Object
« Reply #6 on: September 26, 2019, 04:04:03 PM »
Did you try the utility I referenced, e.g. (mapcar 'print (_FindProjIDs "*excel*")) and if so what was the result?

I used that utility a few weeks ago to find all possible progids to use in autocad (used "*"). I tested vlax-create-object on each one. Not all of them worked, some returned errors, others simply nil. A couple of them took so long to create it was like an infinite loop.

Surely more than that was returned, especially if excel is installed as you say.

What if there is a case where you can have excel installed, but activeX is disabled?

MP

  • Seagull
  • Posts: 17446
Re: Unable to create Excel Object
« Reply #7 on: September 26, 2019, 04:13:40 PM »
Not all progids are associated with an application executable, nor are all instantiable.

I canít speak to an AutoCAD instance where ActiveX has been disabled because Iíve not encountered that scenario.

Cheers.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Mikosalm

  • Mosquito
  • Posts: 5
Re: Unable to create Excel Object
« Reply #8 on: September 26, 2019, 06:17:21 PM »
Quote
Surely more than that was returned, especially if excel is installed as you say.

What's the expected result? I am getting the above on a workstation which can create an Excel object as well.

I can see that Excel is in the registry and I am also able to create objects for other Office applications like Outlook.
Code - Auto/Visual Lisp: [Select]
  1. (vl-registry-descendents "HKEY_CURRENT_USER\\Software\\Microsoft\\Office")

("Word" "Teams" "PowerPoint" "Outlook" "OneNote" "Lync" "Excel" "DmsClient" "Common" "8.0" "16.0" "15.0" "14.0" "12.0" "11.0")

Quote
What if there is a case where you can have excel installed, but activeX is disabled?

Wouldn't that prevent macro's from running as well? Excel appears to be fully functional.

MP

  • Seagull
  • Posts: 17446
Re: Unable to create Excel Object
« Reply #9 on: September 26, 2019, 07:19:09 PM »
I'd expect to see a list of matching progids for a spec of "*excel*", something like:

        "Excel.Application.14"
        "Excel.Chart.5"
        "Excel.Chart.8"
        "Excel.ChartApplication.14"
        "Excel.OpenDocumentSpreadsheet.12"
        "Excel.Sheet.12"
        "Excel.Sheet.5"
        "Excel.Sheet.8"
        "Excel.SheetBinaryMacroEnabled.12"
        "Excel.SheetMacroEnabled.12"
        "ExcelAddIn.Connect.15"
        "ExcelAddIn.Connect.5"
        "ExcelChart"
        "ExcelMacrosheet"
        "ExcelWorksheet"
        "VS15ExcelAdaptor.1"
   
Not:

        "AdobePDFMakerX.ExcelSheetsDlg"

Don't know what to tell you.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Mikosalm

  • Mosquito
  • Posts: 5
Re: Unable to create Excel Object
« Reply #10 on: September 26, 2019, 09:57:24 PM »
Turns out the error was unrelated to AutoCAD. It was fixed by repairing the Office install.

Unsure why your function isn't working though.

Thank you for the responses.

MP

  • Seagull
  • Posts: 17446
Re: Unable to create Excel Object
« Reply #11 on: September 26, 2019, 10:03:27 PM »
I respectfully submit - the function works - your registry is/was wack - glad you appear to have it sorted.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox