Open File with Spaces in Path

  • Thread starter Thread starter J
  • Start date Start date
J

J

Greetings All

I'm having trouble opening files (of any type) which
contain spaces in the path and/or filename. I'd like to be
able to do this. Any help here would be appreciated.

J
 
Enclose the entire "path name\file name" in double quotation marks.
 
Right now I'm using the following which has double quotes:

Shell "excel C:\Sample Path\Sample File.xls",
vbMaximizedFocus

Please advise, and thanks for your help!

J
 
I'm having the same trouble that you did. I'm using this:

Excelstr = "EXCEL.EXE" + " " + Forms![data import]![Viewer Filename]
Call Shell(Excelstr, 1)

The "Viewer Filename" is a path that has spaces in it and excel cuts off the
path wherever there is a space and tries to open a file. If there are two
spaces in the path, ie C:\Data from Calgary.xls is interpreted as
C:\Data.xls, from.xls, and Calgary.xls. Did you ever figure this out?
 
Did you try enclosing in double quotes. If you have quotes enclosed
then you have to double the enclosed quotes.

Another thing to try would be to use %20 instead of the space
for within the pathname.
filename = Replace(filename, " ", "%20")


t.roff said:
I'm having the same trouble that you did. I'm using this:

Excelstr = "EXCEL.EXE" + " " + Forms![data import]![Viewer Filename]
Call Shell(Excelstr, 1)

The "Viewer Filename" is a path that has spaces in it and excel cuts off the
path wherever there is a space and tries to open a file. If there are two
spaces in the path, ie C:\Data from Calgary.xls is interpreted as
C:\Data.xls, from.xls, and Calgary.xls. Did you ever figure this out?




J said:
Right now I'm using the following which has double quotes:

Shell "excel C:\Sample Path\Sample File.xls",
vbMaximizedFocus

Please advise, and thanks for your help!

J
 
Thanks! I was trying to put double quotations in the code, but what worked
was to put double quotes around the pathname in the form.

David McRitchie said:
Did you try enclosing in double quotes. If you have quotes enclosed
then you have to double the enclosed quotes.

Another thing to try would be to use %20 instead of the space
for within the pathname.
filename = Replace(filename, " ", "%20")


t.roff said:
I'm having the same trouble that you did. I'm using this:

Excelstr = "EXCEL.EXE" + " " + Forms![data import]![Viewer Filename]
Call Shell(Excelstr, 1)

The "Viewer Filename" is a path that has spaces in it and excel cuts off the
path wherever there is a space and tries to open a file. If there are two
spaces in the path, ie C:\Data from Calgary.xls is interpreted as
C:\Data.xls, from.xls, and Calgary.xls. Did you ever figure this out?




J said:
Right now I'm using the following which has double quotes:

Shell "excel C:\Sample Path\Sample File.xls",
vbMaximizedFocus

Please advise, and thanks for your help!

J

-----Original Message-----
Enclose the entire "path name\file name" in double
quotation marks.

J wrote:
Greetings All

I'm having trouble opening files (of any type) which
contain spaces in the path and/or filename. I'd like to
be
able to do this. Any help here would be appreciated.

J
.
 

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

Back
Top