I'm trying to open a PDF file (path and filename supplied through a string) from VBA code. I've played around with two solutions so far that both don't really do what I want:
1. Using Shell:
Shell ("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & strFileName)
This works fine on my own system but since it relies on Acrobat Reader 7.0 specifically and it being installed in its default folder, this is not going to be reliable enough for my customers. I'd want Windows to decide for itself what to use to open the .pdf with, same way as if you'd double click it in an Explorer window.
Then after searching this forum for a bit I came up with:
2. Using the FollowHyperLink method:
FollowHyperLink strFileName
Unfortunately, when I do this, I see the Acrobat Reader window flash by; it pops up then immediately closes again. The exact same approach works fine if I try it on a .txt or a .doc, for instance (opening them in Notepad and Word respectively) but apparently Acrobat doesn't like it.
Is there something else I could try here? Anything that will just simulate doubleclicking the file in question in Explorer - letting Windows determine what PDFs should be opened with - would work fine.
"Any fool can defend his or her mistakes; and most fools do." -- Dale Carnegie
1. Using Shell:
Shell ("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & strFileName)
This works fine on my own system but since it relies on Acrobat Reader 7.0 specifically and it being installed in its default folder, this is not going to be reliable enough for my customers. I'd want Windows to decide for itself what to use to open the .pdf with, same way as if you'd double click it in an Explorer window.
Then after searching this forum for a bit I came up with:
2. Using the FollowHyperLink method:
FollowHyperLink strFileName
Unfortunately, when I do this, I see the Acrobat Reader window flash by; it pops up then immediately closes again. The exact same approach works fine if I try it on a .txt or a .doc, for instance (opening them in Notepad and Word respectively) but apparently Acrobat doesn't like it.
Is there something else I could try here? Anything that will just simulate doubleclicking the file in question in Explorer - letting Windows determine what PDFs should be opened with - would work fine.
"Any fool can defend his or her mistakes; and most fools do." -- Dale Carnegie