View Single Post
 
Old 12-21-2024, 06:01 AM
hungt hungt is offline Windows XP Office 2010
Banned
 
Join Date: Jan 2020
Posts: 2
hungt is on a distinguished road
Default

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