Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2024, 06:47 AM
Casey Casey is offline VBA for submit to email Windows 10 VBA for submit to email Office 2021
Novice
VBA for submit to email
 
Join Date: Nov 2024
Posts: 1
Casey is on a distinguished road
Default VBA for submit to email


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
Reply With Quote
Reply



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
VBA for submit to email 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
VBA for submit to email Macro for submit email AmyScott Excel Programming 2 12-29-2014 09:28 AM
VBA for submit to email Email submit that... antipelagian Word VBA 3 02-12-2013 12:07 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft