Startapp won't run seemingly due to spaces in the filepath and name

Startapp won't run seemingly due to spaces in the filepath and name

peter_thomson
Advocate Advocate
670 Views
6 Replies
Message 1 of 7

Startapp won't run seemingly due to spaces in the filepath and name

peter_thomson
Advocate
Advocate

I want to open a spreadsheet from a button on a toolbar using lisp..

 

The code I have is this...

 

(STARTAPP "C:/Program Files (x86)/Microsoft Office/root/Office16/EXCEL.EXE" "C:/Data/AP CAD Tools/Plot/Stantec-Drawing Registry.XLSM")

 

Excel opens but it stumbles on the filename to open at the first space in the filepath..

peterthomson_0-1627556287364.png

 

Any tricks to overcome this?

Comments welcomed.

 

Cheers, Peter T

 

 

0 Likes
Accepted solutions (2)
671 Views
6 Replies
Replies (6)
Message 2 of 7

hak_vz
Advisor
Advisor

@peter_thomson  Try this

 

(STARTAPP "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE" "C:\\Data\\AP CAD Tools\\Plot\\Stantec-Drawing Registry.XLSM")

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 7

pbejse
Mentor
Mentor
Accepted solution

You can also consider using this

;; Open  -  Lee Mac
;; A wrapper for the 'Open' method of the Shell Object
;; target - [int/str] File, folder or ShellSpecialFolderConstants enum

(defun LM:open ( target / rtn shl )
    (if (and (or (= 'int (type target)) (setq target (findfile target)))
             (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))
        )
        (progn
            (setq rtn (vl-catch-all-apply 'vlax-invoke (list shl 'open target)))
            (vlax-release-object shl)
            (if (vl-catch-all-error-p rtn)
                (prompt (vl-catch-all-error-message rtn))
                t
            )
        )
    )
)

 

(LM:Open "C:/Data/AP CAD Tools/Plot/Stantec-Drawing Registry.XLSM")
(LM:Open "C:\\Data\\AP CAD Tools\\Plot\\Stantec-Drawing Registry.XLSM")

 

HTH

 

0 Likes
Message 4 of 7

hak_vz
Advisor
Advisor

You can also test this method.

(STARTAPP "EXPLORER" "C:\\Data\\AP CAD Tools\\Plot\\Stantec-Drawing Registry.XLSM")

 In this case Windows Explorer will start application that is associated with file extension or offer to select one to use.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 7

john.uhden
Mentor
Mentor

Because of spaces, I think you need to put the target in double quotes...

""C:/Data/AP CAD Tools/Plot/Stantec-Drawing Registry.XLSM""

   maybe even like this...

"\"C:/Data/AP CAD Tools/Plot/Stantec-Drawing Registry.XLSM\""

John F. Uhden

0 Likes
Message 6 of 7

peter_thomson
Advocate
Advocate

Thank you.

I should have looked at Lee Mac's site before I asked.

0 Likes
Message 7 of 7

peter_thomson
Advocate
Advocate
Accepted solution

Thank you all for your responses.

After posting my question, I searched this forum and found an answer.

It is all about adding extra quotes, like this...

 

(startapp "C:/Program Files (x86)/Microsoft Office/root/Office16/EXCEL.EXE" (STRCAT "\"" "C:/Data/AP CAD Tools/Plot/Stantec-Drawing Registry.XLSM" "\""))

 

and it worked a treat.

 

Onward and Upward..

Cheers

0 Likes