Re: shell - open document

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Unfortunately is not that simple.
Folder1/folder2 is just an example. That path that I use is in the program
is different, and I have checked that it is correct. Ehen I paste the
path+filename in the "Run" command in the Start menu (Windows), then the
document opens.
I have also tried to leave out Chr(34) because is seems this gives "".
I have also made sure that I do not have space in pathname or filename.
Still no solution.'

What I want to do is to open a file from VBA code. File might not be office
document. Any suggestion?

Ivyleaf skrev:

On Apr 4, 6:38 pm, Jarle <Ja...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I want to open a document. Document format may vary.

I try with:

Dim f_name as String
Dim Returnvalue as Variant
f_name ="E:\forlder1\folder2\test.pdf"

ReturnValue = Shell("start " & Chr$(34) & f_name Chr$(34) )

According to a tip on a different web-site this should open the file in the
program it is connected to (here: Acrobat Reader).

I always get error message "file not found", but the file is there.
What is wrong?

rgds
Jarle

Hi Jarle,

In your path, you have "Forlder1" which I reckon should maybe be
"Folder1"? This may be all that is wrong with your code.

Cheers,
Ivan.

.