SachAccess
Active member
- Local time
- Today, 11:06
- Joined
- Nov 22, 2021
- Messages
- 391
Hi,
I am trying to add attachment through a button on a Form. I have copied below code (forgot to copy the URL) for my use.
Am getting bug at below line.
'With Application.FileDialog(msoFileDialogFilePicker)'
I am getting bug as Method 'FileDialog' of object '_Application failed.
Can anyone please help me with this. Thanks.
I am trying to add attachment through a button on a Form. I have copied below code (forgot to copy the URL) for my use.
Am getting bug at below line.
'With Application.FileDialog(msoFileDialogFilePicker)'
I am getting bug as Method 'FileDialog' of object '_Application failed.
Can anyone please help me with this. Thanks.
Code:
Private Sub Btn_AttachFile_Click()
Dim varFile As Variant
With Application.FileDialog(msoFileDialogFilePicker)
With .Filters
.Clear
End With
.AllowMultiSelect = False
.InitialFileName = vbNullString
.InitialView = msoFileDialogViewDetails
If .Show = True Then
For Each varFile In .SelectedItems
Me![File] = varFile
Next
Else
MsgBox "No file attached ! "
End If
End With
End Sub