• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

to open pdf when clicking command button after selecting list box

ajaar

Member
Dear Friends,

I have below code to open PDF file from the list box, which is perfectly working with single value, when value of list box is changing, i wanted to change the path accordingly.
list box name is rrno, when i tried to change the code"\Me.rrno"&".pdf, but it is not working.

Any help please, i googled a lot, not succeeded this time.

Appreciate your help.

Code:
ThisWorkbook.FollowHyperlink "C:\PDF file supportings\1052555.pdf"

Regards
Ajaar
 
Hi Deepak,

Thanks for the reply. Please find the file attached here with.
listbox name: arrno
when i select on show button i want to open PDF file. all PDF file saved in the same folder.

Thanks
Ajaar
 

Attachments

  • Listbox.xlsm
    17.9 KB · Views: 27
Have you tried explicitly using the Text property of the listbox like this:
Code:
ThisWorkbook.FollowHyperlink "C:\PDF file supportings\" & Me.arrno.Text & ".pdf"
?
Does this also not work?
 
All is almost well there!!

Just little modified the same.

Code:
Private Sub CommandButton1_Click()
With Me.arrno
    If Not .ListIndex > -1 Then MsgBox "Pls select a file name", vbCritical: Exit Sub
    ThisWorkbook.FollowHyperlink "C:\PDF file supportings\" & .Value & ".pdf"
End With
End Sub

or

Yours.

Code:
Private Sub CommandButton1_Click()
ThisWorkbook.FollowHyperlink "C:\PDF file supportings\" & Me.arrno & ".pdf"
End Sub
 
Back
Top