Banner

Sunday, March 5, 2017

Open PDF File In Userform Excell VBA





Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

'For Open PDF file In Excell Userform

On Error Resume Next

ThisWorkbook.FollowHyperlink "C:\Invoice\" & Me.ListBox1.Column(2) & ".pdf"

End Sub

Private Sub UserForm_Initialize()

'For Listbox Fill Data

Dim i As Long

For i = 1 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))

Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value

For a = 1 To 4

Me.ListBox1.List(ListBox1.ListCount - 1, a) = Sheet1.Cells(i, a + 1).Value

Next a

Next i

Me.ListBox1.Selected(0) = True

End Sub

5 comments:

  1. I am trying to open a PDF file to a specific page using Excel VBA. However, I do NOT want to require any particular Browser or that my 4,000+ users have Acrobat Adobe. Is this possible, and how? Thank you very much. RogerEP46@gmail.com

    ReplyDelete
  2. error Me.ListBox1.Column(2)

    ReplyDelete
  3. i try this but i have a problem with the listbox can you help me plz

    ReplyDelete
  4. please send the sample file, becouse of my additional control not diplaying
    dhl.shanid@hmail.com

    ReplyDelete
  5. if i search data if will display in my listbox. but when i click list nothings happen or no result it does not display the file.

    Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    'For Open PDF file In Excel Userform
    On Error Resume Next
    Sheet3("Data").FollowHyperlink "C:\Users\DELL\Desktop\PDF\" & Me.ListBox1.Column(4) & ".pdf"
    End Sub

    ReplyDelete

Please do not enter any spam message in comment box