rohrl77 rohrl77 - 1 year ago 67
Bash Question

Execute shell is not opening up file provided as string

I am trying to solve an error in code written by someone else. The shell function running in an MS Excel VBA environment is as follows:

Public Function ExecCmd(cmdline$)
Dim ret&

' Initialize the STARTUPINFO structure:
start.cb = Len(start)

' Start the shelled application:
ret& = CreateProcessA(vbNullString, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)

' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, ret&)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ExecCmd = ret&
End Function

input is: "excel.exe W:\L\BDTP\Products\Mandate FS\OfferToolUpdate.xlsm"

When I run the code it opens another excel instance and attempts to open a file under "W:\L\BDTP\Products\Mandate.xlsx"... after two more error messages it tells me that it can also not find "FS\OfferToolUpdate.xlsm"

Clearly this error is produced some how due to the space in the naming convention of the Folder the file resides in.

How can I open the file without changing the folder name?

Answer Source

I believe you used example as shown at: ...

Just update execution line to wrap out the file:

ExecCmd "excel.exe ""U:\ADMINISTRATION\Expenses\Some File.xlsx"""
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download