In UserForm
Option Explicit
Private Sub CommandButton1_Click()
Dim filename As String
' change "d:\sample.pdf" to the name of an existing file, np. "C:\Users\Tee\Downloads\XYZ.pdf"
filename = "d:\sample.pdf"
WebBrowser1.Navigate filename
MsgBox "Done"
End Sub
Private Sub CommandButton2_Click()
Dim filename As String
' first select - select one item in ListBox1, only then click CommandButton2
filename = ListBox1.List(ListBox1.ListIndex) ' selected item in ListBox1
WebBrowser1.Navigate filename
End Sub
Private Sub UserForm_Initialize()
'Dim MyFolder As String
'Dim MyFile As String
'Dim j As Integer
' MyFolder = "C:\Users\Tee\Downloads"
' MyFile = Dir(MyFolder & "\*.pdf")
' Do While MyFile <> ""
' ListBox1.AddItem MyFile
' MyFile = Dir
' Loop
End Sub
|