Not real clear on what you are looking for. Do you want to run the code for a Command_Click from some other subroutine or are you looking to run the code when the button is pushed? For the latter, you can simply double-click the command button and the sub will be started. If you wish to call the Click routine, simply Call CmdBtnName_Click, where CmdBtnName is the name of the button.
I have an event titled "Private Sub Email_Request", please see the code below,
Private Sub Email_Request()
'open Outlook and send me a pre-formatted email with update info
'create new message
Set objOutlk = CreateObject("Outlook.Application"
Set objMail = objOutlk.createitem(olMailItem)
objMail.To = "jjackelini@amerisource.com"
objMail.Subject = "Phone Book Update Request"
'add body
strMsg = "Last Name: " & vbCrLf
strMsg = strMsg & "First Name: " & vbCrLf
strMsg = strMsg & "What needs Corrected: " & vbCrLf & vbCrLf & vbCrLf & vbCrLf
strMsg = strMsg & "** Your request will be processed in the next" & vbCrLf
strMsg = strMsg & "update...please be patient...I update records" & vbCrLf
strMsg = strMsg & "approx. twice a month. <Brad>**"
objMail.body = strMsg
'this previews email prior to sending
objMail.Display
'this send automatically
'objMail.display
Set objMail = Nothing
Set objOutlk = Nothing
I want to be able to have the user click the command button connected tot his VBA code. The code is not correct, what I want is for an attachment to be automatically attached when the Command button is depressed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.