TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pedroantonio on January 12, 2018, 04:03:51 PM

Title: Open excel file (*.xlsx) with autocad command
Post by: pedroantonio on January 12, 2018, 04:03:51 PM
Hi .I have an (*.xlsx) file in a folder with the name Test in C drive. I am using Autocad 2017 and Office  2016

I write the command

Code: [Select]
^c^c(startapp C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\" \"C:\\Test\\My test.xlsx\"")

and gives me this error

Quote
Unknown command STARTAPP

Any ideas
Title: Re: Open excel file (*.xlsx) with autocad command
Post by: dubb on January 12, 2018, 04:34:01 PM
Try this
Code: [Select]
(startapp "C:/Program Files (x86)/Microsoft Office/root/Office16/excel.exe" "\"C:\\Test\\My test.xlsx\"")
Hi .I have an (*.xlsx) file in a folder with the name Test in C drive. I am using Autocad 2017 and Office  2016

I write the command

Code: [Select]
^c^c(startapp C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\" \"C:\\Test\\My test.xlsx\"")

and gives me this error

Quote
Unknown command STARTAPP

Any ideas
Title: Re: Open excel file (*.xlsx) with autocad command
Post by: ChrisCarlson on January 12, 2018, 04:34:31 PM
Well, the full path is required, including excel.exe. Second, the unknown command is triggering as it's the default error that the command did not run properly.
Title: Re: Open excel file (*.xlsx) with autocad command
Post by: ronjonp on January 12, 2018, 04:51:53 PM
Alternatively:

Code - Auto/Visual Lisp: [Select]
  1. (defun _openfile (file / sh)
  2.   (setq sh (vlax-get-or-create-object "Shell.Application"))
  3. )
  4. (_openfile "C:\\Test\\My test.xlsx")
Title: Re: Open excel file (*.xlsx) with autocad command
Post by: Grrr1337 on January 12, 2018, 04:56:26 PM
This was suggested by Lee Mac:
Code - Auto/Visual Lisp: [Select]
  1. (startapp (vl-registry-read (strcat "HKEY_CLASSES_ROOT\\" (vl-registry-read "HKEY_CLASSES_ROOT\\.xls") "\\shell\\new\\command")))
Title: Re: Open excel file (*.xlsx) with autocad command
Post by: pedroantonio on January 12, 2018, 05:11:45 PM
Thank you for the help