Reputation: 1
This is what I want it to do. They open the document, fill in the form and when they hit the submit button it will print the filled in document, save it as a different name with user input and then is supposed to email the new document with the data too. Everything is working except it is not e-mailing the new document.
I need either the complete document they have filled in to be emailed or the content that they filled in as an attachment.
Here is my code:
Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Application.ActiveDocument.PrintOut
Dim strDocName As String
Dim intPos As Integer
'Ask the user to provide a filename
strDocName = InputBox("Please enter the name " & _
"of your document.")
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocument
Options.SendMailAttach = True
ActiveDocument.SendMail
End Sub
Upvotes: 0
Views: 52
Reputation: 1111
At some point, "ActiveDocument" switches from the new document to the old one. You must refer to the new one explicitly.
I'm not sure at what point the switchover occurs, but try this.
Change:
Options.SendMailAttach = True
ActiveDocument.SendMail
To:
Dim MailDoc as Document
Set MailDoc = ActiveDocument
Options.SendMailAttach = True
MailDoc.SendMail
Upvotes: 1