Passing strings with blank spaces into WinExec function call

J

JDB

Good Morning from San Diego;
I am having problems using the WinExec function when I call for a file
to be run when there are blank spaces in the path.

I am attaching 2 subroutine calls; The first on works, the second one
does not, and it is because of the blank spaces.

Any help or suggestions welcomed.

JDB



1. Works
---------------
Sub ExecMplFile()
Dim RetVal
Dim strProgDirectory As String


Dim strFileDirectory As String
Dim strFile As String
strProgDirectory = "c:\mplwin4\mplwin42.exe solve "
strFileDirectory = "C:\Albacora\Albacora.mpl"

strFile = strProgDirectory & strFileDirectory

Call WinExecWait(strFile)

msgbox "Finished Albacora"

End Sub

2. Does NOT work
-------------------------------------------------------------------------------

Sub ExecMplFile()
Dim RetVal
Dim strProgDirectory As String

Dim strFileDirectory As String
Dim strFile As String
strProgDirectory = "c:\mplwin4\mplwin42.exe solve "

strFileDirectory = "C:\Documents and Settings\jdebeer\My Documents
\10_LP_Problems\MPL_Files\Albacora_Test\Albacora.mpl"

strFile = strProgDirectory & strFileDirectory

msgbox strFile

Call WinExecWait(strFile)

msgbox "Finished Albacora"

End Sub
 
R

Ralph

Try concatenating Chr(34) to your directory name.

strFile = strProgDirectory & chr(34) & strFileDirectory & chr(34)
 
J

JDB

Tried it. The double quotes showed up around the string in the msg
box, but the program did NOT execute.

Thanks for your suggestion.

JDB
 
J

JDB

My deepest apologies;
This worked perfectly.


Try concatenating Chr(34) to your directory name.
strFile = strProgDirectory & chr(34) & strFileDirectory & chr(34)

Thanks so much.

JDB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top