Open external application file with parameter using VBA

G

Guest

I have had some great help on my earlier question on the subject of opening an external application file using VBA. I am now faced with a new problem and would appreciate some help.

When I run Shell "MyComputer\Myfolder\AcroRd32.exe C:\Myfile.pdf" it works fine.

When I assign say Selectfile="C:\Myfile.pdf" and run Shell "MyComputer\Myfolder\AcroRd32.exe Selectfile", an error message is displayed by Acrobat - "There was an error opening this document. The file does not exist.
 
V

Vasant Nanavati

You are mixing strings and variables. Try (untested):

"MyComputer\Myfolder\AcroRd32.exe " & Selectfile

Note the space at the end of the first substring.

--

Vasant

Francis Ang said:
I have had some great help on my earlier question on the subject of
opening an external application file using VBA. I am now faced with a new
problem and would appreciate some help.
When I run Shell "MyComputer\Myfolder\AcroRd32.exe C:\Myfile.pdf" it works fine.

When I assign say Selectfile="C:\Myfile.pdf" and run Shell
"MyComputer\Myfolder\AcroRd32.exe Selectfile", an error message is displayed
by Acrobat - "There was an error opening this document. The file does not
exist."
 
G

Guest

Thanks Vasant. Sorry there was an error in my question. I actually ran this VBA code Shell "MyComputer\Myfolder\AcroRd32.exe " & Selectfile , where Selectfile="C:\Myfile.pdf" but got an error message.
 
V

Vasant Nanavati

Francis, this worked for me from the Immediate Window:

strFile = "C:\Documents and Settings\Administrator\My
Documents\Vasant\IndustryBrains\IndustryBrains.pdf":Shell "C:\Program
Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe " & strFile

Watch the line wrap.

I'm not sure why you are using My Computer instead of the drive letter.
Perhaps that is the problem.

--

Vasant

Francis Ang said:
Thanks Vasant. Sorry there was an error in my question. I actually ran
this VBA code Shell "MyComputer\Myfolder\AcroRd32.exe " & Selectfile , where
Selectfile="C:\Myfile.pdf" but got an error message.
 

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