View Single Post
 
Old 12-21-2024, 04:32 AM
Tee Tee is offline Windows 10 Office 2021
Novice
 
Join Date: Dec 2024
Posts: 3
Tee is on a distinguished road
Default

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 View Post
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
Reply With Quote