Hi
I am using the following code to attach a document (pdf, .xls, .doc) to a record but get the error
User-defined type not defined. Help please
I am using the following code to attach a document (pdf, .xls, .doc) to a record but get the error
User-defined type not defined. Help please
Code:
Private Sub GetAttachment_Click()
On Error GoTo Err_GetAttachment_Click
Dim dlgAttach As FileDialog
Dim strMyFile As String
Dim varChosen As Variant
Set dlgAttach = Application.FileDialog(msoFileDialogFilePicker)
With dlgAttach
.ButtonName = "Attach"
.InitialView = msoFileDialogViewList
.Title = "Choose file to attach"
.AllowMultiSelect = False
'Set up file types
With .Filters
.Clear
.Add "Word Documents", "*.doc"
.Add "Excel Spreadsheets", "*.xls"
.Add "Adobe PDFs", "*.pdf"
.Add "Powerpoint Presentations", "*.ppt"
End With
'Set default file type
.FilterIndex = 1
'Show Dialog Box
If .Show = -1 Then
For Each varChosen In dlgAttach.SelectedItems
strMyFile = varChosen
Next varChosen
End If
End With
'Dump the chosen file name into a text control on the form
Forms!frmClientOverview!frmAddNewDocument!Location = strMyFile
Exit_GetAttachment_Click:
Exit Sub
Err_GetAttachment_Click:
MsgBox Err.Description
Resume Exit_GetAttachment_Click
End Sub