Author Topic: Unable to create Excel Object  (Read 4104 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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

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: 17750
  • Have thousands of dwgs to process? Contact me.
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?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

jtoverka

  • Newt
  • Posts: 127
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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

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: 17750
  • Have thousands of dwgs to process? Contact me.
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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

AthenaBonilla

  • Mosquito
  • Posts: 1
Re: Unable to create Excel Object
« Reply #12 on: May 07, 2023, 10:13:16 PM »
Hi. I had the same problem with Excel a few days ago. I'm really sorry for bumping. Just need your help.

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Unable to create Excel Object
« Reply #13 on: May 08, 2023, 03:34:51 AM »
With excel 2 scenarios is open or is not

Code: [Select]
(or (setq myxl (vlax-get-object "Excel.Application"))
    (setq myxl (vlax-get-or-create-object "excel.Application"))
)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)
A man who never made a mistake never made anything

RishiRamos

  • Mosquito
  • Posts: 1
Re: Unable to create Excel Object
« Reply #14 on: May 09, 2023, 07:46:38 PM »
Hey. Have you tried updating your Office version to the latest one? That might solve the issue. By the way, have you checked out Office 2021 Professional Plus for Windows? It's the latest and greatest version with all the bells and whistles. I'm new on this forum, but I can tell you that turnkeypoint.com is a great resource for all things tech-related. Hope this helps!
« Last Edit: May 11, 2023, 01:08:52 AM by RishiRamos »