Solved: ShellExecute for PDF documents with OpenActions
Hopefully some of you smart Excel VBA programmers can help with this one.
Hi! I'm currently working on a VBA project within ArcMap. Although many of you will be unfamiliar with this program, my question can be extended to most of you since ShellExecute can be used for programs that support VBA.
My previous design was simplified, and used the standard 'Shell' command. I was able to pass OpenActions without any difficulties. The code for this was:
[vba]
Dim strPath1, strPath2, strPath3 as string
strPath1 = """C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"""
strPath2 = "/A page=13=OpenActions""
strPath3 = "C:\DocumentA.pdf"
Shell strPath1 & " " & strPath2 & " " & strPath3, vbNormalFocus
[/vba]
This worked like a charm. However, it's extremely limiting as the program cannot easily be distributed since it requires Adobe Reader 9.0.
After some research I discovered that ShellExecute can perform this task using any version of Reader, however it seems to be unable to accept the OpenActions (in this situation page #). Here's the code for the ShellExecute command.
[vba]
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) _
As Long
Private Declare Function GetDesktopWindow Lib "User32" () As Long
Const SW_SHOWNORMAL = 1
Private Sub cmdPDF_Click()
nDT = GetDesktopWindow()
nApp = ShellExecute(nDT, "Open", "C:\DocumentA.pdf", "", "C:\", SW_SHOWNORMAL)
End Sub
[/vba]
I've tried several different methods, placing the 'OpenAction' in several different places with no success. If anyone can tell me...
a) If it's possible to use OpenActions with the ShellExecute
b) How to solve this issue if it is
Cheers,
Cameron