Thank you hungt for the code. I tried but it did not work. The webbroswer1 open google search with the file name and some javascript error comes up.
The below code is in Userform initialise section:
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
I removed it and the code which you provided still didn't worked. I changed the folder location etc correctly.
Any idea what could be wrong or missing?
I appreciate your help.
Thank you.
Quote:
Originally Posted by hungt
Private Sub CommandButton1_Click()
Dim filename As String
' filename = "d:\myPDF.pdf" ' file path
filename = ListBox1.List(ListBox1.ListIndex) ' selected item in ListBox1
WebBrowser1.Navigate filename
End Sub
|