• 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.

Macro not working in VBA

Hi. I cannot figure out where my VBA is incorrect. Can you take a look and help? I have attached the VBA and the template worksheet. The button that says "browse for pdf" should be filling in the template location (the pdf template is also attached). Any suggestions? TIL!
 

Attachments

  • blank_statement_fillable.pdf
    117.4 KB · Views: 5
  • test project excel.xlsm
    26.7 KB · Views: 3
Code:
Sub SetPDFTemplate()
    Dim PDFFile     As FileDialog
    Set PDFFile = Application.FileDialog(msoFileDialogFilePicker)
    With PDFFile
        .Title = "Select PDF Form"
        .Filters.Add "PDF Type Files", "*.pdf", 1
        If .Show <> -1 Then GoTo Noselection
        Sheet1.Range("E5").Value = .SelectedItems(1)
    End With
    Noselection:
End Sub
 
Back
Top