![]() |
|
#1
|
|||
|
|||
|
Hi ,
I try to create a VBA where the 1st button goes to a email for authorisation, the approver then can send the form to accounts. Code:
Private Sub CommandButton1_Click()
Dim xOutlookObj As Object
Dim xEmail As Object
Dim xDoc As Document
Application.ScreenUpdating = False
Set xOutlookObj = CreateObject("Outlook.Application")
Set xEmail = xOutlookObj.CreateItem(olMailItem)
Set xDoc = ActiveDocument
xDoc.Save
With xEmail
.Subject = "Overtime Form"
.Body = "Hi, please use email as approval for overtime; please process for month-end payroll."
.To = "Accounts@............"
.Importance = olImportanceNormal
.Attachments.Add xDoc.FullName
.Display
End With
Set xDoc = Nothing
Set xEmail = Nothing
Set xOutlookObj = Nothing
Application.ScreenUpdating = True
End Sub
End Sub
Private Sub CommandButton2_Click()
Dim xOutlookObj As Object
Dim xEmail As Object
Dim xDoc As Document
Application.ScreenUpdating = False
Set xOutlookObj = CreateObject("Outlook.Application")
Set xEmail = xOutlookObj.CreateItem(olMailItem)
Set xDoc = ActiveDocument
xDoc.Save
With xEmail
.Subject = "Overtime Form"
.Body = "Hi, please authorise and send to Accounts for payroll processing."
.To = "overtime@........"
.Importance = olImportanceNormal
.Attachments.Add xDoc.FullName
.Display
End With
Set xDoc = Nothing
Set xEmail = Nothing
Set xOutlookObj = Nothing
Application.ScreenUpdating = True
End Sub
it seems that the xDoc.Save is trying to save it after pressing the button to payroll??? Can someone please advise? Thank you Last edited by macropod; 11-21-2024 at 03:26 PM. Reason: Added code tags & formatting |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with submit button to email form | JoeFreeman | Word VBA | 1 | 01-28-2023 05:20 PM |
Submit Button Req that populates email address
|
phorsley | Word VBA | 1 | 10-17-2017 04:50 PM |
| Submit to Email Command Button | rob7676 | Word VBA | 0 | 08-20-2015 05:05 AM |
Macro for submit email
|
AmyScott | Excel Programming | 2 | 12-29-2014 09:28 AM |
Email submit that...
|
antipelagian | Word VBA | 3 | 02-12-2013 12:07 PM |