Author Topic: Excel Wildcard  (Read 416 times)

0 Members and 1 Guest are viewing this topic.

Offline TonyHolsingerTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Country: us
  • Gender: Male
Excel Wildcard
« on: Jan 03, 2018, 07:20:11 PM »
Can somebody give me a hand with this? I am trying to get Autocad to open Excel. Unfortunately some user machines are still running office 2014, while others are running 2016 (I've even seen one with both  ???). Is there a way to "Wildcard" the folder? I tried with the code below, but with no luck.

Code: [Select]
(Setq Excel(StrCat "C:\\Program Files (x86)\\Microsoft Office\\" "Office**" "\\Excel.exe"))

Offline Darren Young

  • Premier Member
  • *****
  • Posts: 1365
  • Country: us
  • Gender: Male
    • Hermancon Company LLP
Re: Excel Wildcard
« Reply #1 on: Jan 03, 2018, 08:02:08 PM »
You're likely better off just doing a (findfile) call on the different paths and the one that returns is the one you use. Shouldn't be that many iterations of the path.

You can also get this from the registry...likely the best place to look is the PATH value of this key...

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe

Assuming that the different Excel version all use similar registry keys.

Other possible registry keys you could use are...

HKEY_CLASSES_ROOT\ExcelWorksheet\Protocol\StdFileEditing\Server
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Extensions
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExcelWorksheet\Protocol\StdFileEditing\Server
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ms-excel\DefaultIcon
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Classes\ExcelChart\protocol\StdFileEditing\server
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\REGISTRY\MACHINE\Software\Classes\ExcelWorksheet\protocol\StdFileEditing\server

Offline TonyHolsingerTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Country: us
  • Gender: Male
Re: Excel Wildcard
« Reply #2 on: Jan 03, 2018, 08:45:00 PM »
Thanks Darren. I was able to get to it with the following code, in case anybody ever needs it in the future. Essentially it just finds the path to the current users excel folder and then runs the "Excel.exe" from there. 

Code: [Select]
(setq excel (vlax-get-or-create-object "Excel.Application"))
(setq excelpath (vlax-get-property excel 'Path))
(setq RunExcel (strcat excelpath "\\\Excel.exe"))
(Startapp RunExcel)

Offline Darren Young

  • Premier Member
  • *****
  • Posts: 1365
  • Country: us
  • Gender: Male
    • Hermancon Company LLP
Re: Excel Wildcard
« Reply #3 on: Jan 03, 2018, 11:08:07 PM »
Thanks Darren. I was able to get to it with the following code, in case anybody ever needs it in the future. Essentially it just finds the path to the current users excel folder and then runs the "Excel.exe" from there. 

Code: [Select]
(setq excel (vlax-get-or-create-object "Excel.Application"))
(setq excelpath (vlax-get-property excel 'Path))
(setq RunExcel (strcat excelpath "\\\Excel.exe"))
(Startapp RunExcel)

Look at the task manager before and after the "get-or-create" object call. You're actually launching Excel with this method. In which case, all you need is this...

Code: [Select]
(setq excel (vlax-get-or-create-object "Excel.Application"))
(vlax-put-property excel "Visible" 1)

Offline TonyHolsingerTopic starter

  • Full Member
  • ***
  • Posts: 138
  • Country: us
  • Gender: Male
Re: Excel Wildcard
« Reply #4 on: Jan 05, 2018, 01:14:26 PM »
Sorry i wasn't more specific, I do ultimately want to end up launching excel and open a specific macro enabled file. The problem was the different versions of excel between the different machines.