Preview PDF file in acroPDF from listbox

Wicked_

Board Regular
Joined
Jun 5, 2018
Messages
81
Hi.

I have a problem.
I have a listbox, and a acroPDF, and i would like it to when i press a filename(.pdf) in the listbox, that it previews the PDF file in the acroPDF.

For the listbox, i have a browse button, that makes you select a folder:
Code:
Private Sub select_Image_1_Click()


Dim MyFolder As String
Dim MyFile As String


With Application.FileDialog(msoFileDialogFolderPicker)


If .Show = -1 Then


ListBox1.Clear


TextBox1.Text = .SelectedItems(1)
MyFile = Dir(.SelectedItems(1) & "\*.pdf")
Do While MyFile <> ""


ListBox1.AddItem MyFile
MyFile = Dir
Loop
End If
End With
End Sub

Then when i select that folder, all the pdf files within that folder shows, and when i click the desired pdf file, i need to make it show in the acroPDF.

If i then use :
Code:
Me.AcroPDF1.LoadFile "C:\04.pfd"
it will then show that file correctly, but only show that spesific file.

How do i make it show the file that i am actually selecting, from the listbox ? (recap: i browse to a spesific folder which contains the pfd files i want to show, then press that file from the listbox, then i want that file to be showned in the acroPDF)


Thanks in advance.
 
Last edited by a moderator:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Presumably this should work:

Code:
Me.AcroPDF1.LoadFile TextBox1.Text & "\" & ListBox1.Value
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top