viewing .pdf file with command button

2144
1
04-29-2011 07:32 AM
arennaz
New Contributor
I want to add some Help buttons to a user form that will pull up a .PDF or .HTML file that the User can use to learn how to use the form correctly.

i used the code below but get an error says "Only comments may appear after End Sub, End function or End property" . how do I fix this?

Private 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

Private Sub help_Click()
    Dim strFileToOpen As String
    strFileToOpen = "helpfiletoolbox.pdf"
    Dim strFolder As String
    strFolder = "h:\"
   
    Call ShellExecute(0, vbNullString, strFileToOpen, vbNullString, strFolder, 1)
End Sub
0 Kudos
1 Reply
JamesCrandall
MVP Frequent Contributor
I am not sure if the ShellExecute function is completed or not, what code needs to be in it, but it is missing an End Function.  See:

Private 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

'while the End Function below would get rid of your error
'I don't know what (if anything) code should be in this Function

End Function
0 Kudos