Space problem

  • Thread starter Thread starter Terry
  • Start date Start date
T

Terry

I'm trying to open an Excel file from a form. The file lives in a subfolder
of My Documents. The subfolder name is comprised of two words, as is the
file I'm trying to open. For some reason the code below can't cope with the
spaces in these names. It works fine when I replace spaces with underscores
(all round), but that's not a suggestion I want to make.

stAppName = "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE sub
folder\Weekly Roster.xls"

I've tried various permutations of double- and single-quotes, but have so
far been unsuccessful.

TIA
Terry
 
I'm trying to open an Excel file from a form. The file lives in a subfolder
of My Documents. The subfolder name is comprised of two words, as is the
file I'm trying to open. For some reason the code below can't cope with the
spaces in these names. It works fine when I replace spaces with underscores
(all round), but that's not a suggestion I want to make.

stAppName = "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE sub
folder\Weekly Roster.xls"

I've tried various permutations of double- and single-quotes, but have so
far been unsuccessful.

Try

stAppName = """C:\Program Files\Microsoft Office\Office10\EXCEL.EXE""
""sub folder\Weekly Roster.xls"""

Two consecutive " characters are interpreted as a " - this will let
the program realize that

C:\Program Files\Microsoft Office\Office10\EXCEL.EXE

is one single object, while

sub folder\Weekly Roster.xls

is a different one.
 
stAppName = "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE sub
Try

stAppName = """C:\Program Files\Microsoft Office\Office10\EXCEL.EXE""
""sub folder\Weekly Roster.xls"""

Two consecutive " characters are interpreted as a " - this will let
the program realize that

C:\Program Files\Microsoft Office\Office10\EXCEL.EXE

is one single object, while

sub folder\Weekly Roster.xls

is a different one.

John W. Vinson[MVP]

Aaaah, fabulous. Thank you John.
 
Back
Top