Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SIMPLE RUN CMD Question for all Users

Status
Not open for further replies.

Jack58

Technical User
May 6, 2002
91
US
I need to know the code to run a Command Button from a VBA Event Procedure I wrote. I have used the code before, but not for some time.

Hope someone can help me out with this simple task.


Thanks in Advance.



Jack
 
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 & &quot;approx. twice a month. <Brad>**&quot;
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.

I hope you can help me with this one.


Thanks!!!!


Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top