Hello all...
I have a Userform Module that calls GetOpenFilename to attach a file to an email. I used the following two subs to do that:
Now, it seems to work locally as, when I put the item in Display mode, the email shows with the attachment. However, when I put the form into Send mode, I get the following Run-time error:
(Not sure if it is going to display)
"Run-time error '-2147221238 (8004010a)': The item has been moved or deleted."
The Error is breaking on the Attachments.Add property. However, when I add a breakpoint and hover, it does display the path to the selected document. Due to error-handling, the email does send but the attachment is not included.
In display mode, I get a Run-time 438 error message (Object doesn't support this property or method)on the If Else statement. However, again, the item does show as attached.
Does anyone have any suggestions for this? Any help is, as always, greatly appreciated!
I have a Userform Module that calls GetOpenFilename to attach a file to an email. I used the following two subs to do that:
Code:
Private Sub cmdRescAttach_Click()
'The following code is for designating an attachment from the user's computer. Works in conjunction with Attachment.Add method in Outmail.
Dim strFileName As Variant
ChDir "C:\" ' change to path to start dialog in
strFileName = Application.GetOpenFilename(, , "Choose file for Escalation", , False)
If TypeName(strFileName) = "String" Then
tbRescDocAttached.Value = strFileName
Else
MsgBox "No attachment selected"
End If
End Sub
Code:
.Attachments.Add EscalationsForm.tbRescDocAttached.Value & EscalationsForm.tbUHADocAttached.Value & EscalationsForm.tbRSCDocAttached.Value
If tbRescDocAttached.Value <> "" Then
.Attach tbRescDocAttached.Value
ElseIf tbUHADocAttached.Value <> "" Then
.Attach tbUHADocAttached.Value
ElseIf tbRSCDocAttached.Value <> "" Then
.Attach tbRSCDocAttached.Value
End If
End With
Now, it seems to work locally as, when I put the item in Display mode, the email shows with the attachment. However, when I put the form into Send mode, I get the following Run-time error:
(Not sure if it is going to display)
"Run-time error '-2147221238 (8004010a)': The item has been moved or deleted."
The Error is breaking on the Attachments.Add property. However, when I add a breakpoint and hover, it does display the path to the selected document. Due to error-handling, the email does send but the attachment is not included.
In display mode, I get a Run-time 438 error message (Object doesn't support this property or method)on the If Else statement. However, again, the item does show as attached.
Does anyone have any suggestions for this? Any help is, as always, greatly appreciated!