Open File using Variable Path?

Giganews Newsgroups
Subject: Open File using Variable Path?
Posted by:  Jason Gyetko (jason.gyet…@epower-inc.com)
Date: 23 Aug 2006

I'm trying to open a file from VBA using a variable path and am not
having very much luck.  Can anyone help?

This works:
retval = Shell("""Excel.EXE"" ""C:\Program files\MyPath\MyFile.xls""",
1)

This does not like the space in 'Program Files':
retval = Shell("Excel.EXE " & Application.CurrentProject.Path &
"\MyFile.xls", 1)

I've tried quotation marks all over the place in all sorts of
combinations and cannot get it to work.  With the above example I get
the following message:

'C:\Program.xls' could not be found...

That one is immediately followed by:

'Files\MyPath\MyFile.xls' could not be found.

Thanks in advance for any suggestions.

Replies