Open PDF from Macro

What is the easiest way of opening PDF file from macro?
This does not work on all computers because different versions of Acrobat
installed on different computers
-- Shell("C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe " &
PdfFileLocation & FileName & ".pdf", vbNormalFocus)
Do I have to specify which program to use to open these files or is there a
way of using windows registered file types.
Reply to
mr.T
Loading thread data ...
There is a very easy way - just call the filename from shell and windows will open it with the default pdf reader.
For example: "C:\temp\mypdf.pdf"
mr.T wrote:
Reply to
Mr. Who
I couldnt get that to work.
Shell "N:\PDFNEW\" & FileName, vbNormalFocus
N:\PDFNEW is the location I save my PDF files.
Any ideas?
Reply to
SW Monkey
Use the Windows API Shell command. That requires you to set up the call to a Windows DLL first.
Don't forget you need to decalre the Windows API function first.
SW M> > There is a very easy way - just call the filename from shell and
Reply to
That70sTick
What is the code after I call the .dll ?
Reply to
SW Monkey
It took a while but this is how I got it to work..
----------------------------
Const SW_SHOWNORMAL = 1 Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute(1, "Open", PdfFileLocation & FileName & ".pdf", "", PdfFileLocation, SW_SHOWNORMAL) ----------------------------
Ps.
Thanks to That70sTick for the pointers..
Now if I could just figure out how to link that DataBase to custom properties ..
Reply to
mr.T
That one works. Thanks.
I modified it to popup a message box if someone doesnt have Adobe installed.
PDFOPEN = ShellExecute(1, "Open", FileName, "", PdfFileLocation, SW_SHOWNORMAL)
If PDFOPEN < 32 Then MsgBox "Adobe Acrobat is not installed, no preview will be shown", vbExclamation, "SAVE2PDF - NO PREVIEW" End If
Reply to
SW Monkey

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.