I am trying to code to allow users to attach a file however I am getting an error when I attempt to attach a .doc, .docx or .pdf. How do I make it so the me.txtpath allows for that?
Code:
Private Sub attachbtn_Click()
Dim dlgOpen As FileDialog
Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.InitialFileName = "Z:\" 'Initial Path when explorer is opened
.Show
If .SelectedItems.Count = 0 Then
msgbox ("No file Selected") 'No file selected
Else
Me.txtPath = .SelectedItems(1) 'sets textbox on the form to the path selected
'Me.img.Picture = txtPath.Value
End If
End With
End Sub