How do I code for a space in a file path?

P

patientgrow

I have a file path I am trying to get to work in Vb Code but I keep getting
an error and it is because there is a space. Below is the path.

"RemittanceApp\Patient Cash\Check_Free\Database\Check.mdb"

Is there a way to get it to recognize the space between Patient Cash?

Thanks
 
S

Stefan Hoffmann

hi,
I have a file path I am trying to get to work in Vb Code but I keep getting
an error and it is because there is a space. Below is the path.
"RemittanceApp\Patient Cash\Check_Free\Database\Check.mdb"
The question is: Where do you use this path? When it comes down to
interact with the OS you need to escape such an path:

"""RemittanceApp\Patient Cash\Check_Free\Database\Check.mdb"""

Otherwise the command line parser and companions think they are dealing
with two tokens instead of one.


mfG
--> stefan <--
 
P

patientgrow

Stefan,

Unfortunatly I can not change the path. Below is the entire code I am
using. The code is supposed to open up this database and run a Macro. I
tried the """ like you suggested but I still get the error.


Filename = "RemittanceApp\Patient Cash\Check_Free\Database\CheckFree.mdb"
ExecutionMacro = " /xmcrImport"
'the directory where the application lives
Directory = "N:\"
'finds where Access itself lives
AppPath = SysCmd(acSysCmdAccessDir) & "MSACCESS.EXE"
'MsgBox AppPath & " " & Directory & Filename
htask = Shell(AppPath & " " & Directory & Filename &
ExecutionMacro, 1)
 
S

Stefan Hoffmann

hi,
Unfortunatly I can not change the path.
That's why you need to enclose it into quotation marks.
htask = Shell(AppPath & " " & Directory & Filename & ExecutionMacro, 1)

htask = _
Shell("""" & AppPath & """ """ & _
Directory & Filename & """ " & _
ExcutionMacro)


mfG
--> stefan <--
 
D

Douglas J. Steele

The problem is because you've separated Directory and FileName

Try:

htask = Shell(AppPath & " """ & Directory & Filename & """" &
ExecutionMacro, 1)

That's one double quote followed by a space followed by three double quotes
in front, and four double quotes afterwards.
 
P

patientgrow

Stefan,
Thank you that worked!

Stefan Hoffmann said:
hi,

That's why you need to enclose it into quotation marks.


htask = _
Shell("""" & AppPath & """ """ & _
Directory & Filename & """ " & _
ExcutionMacro)


mfG
--> stefan <--
 
Top