Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-28-2023, 03:11 PM
JAS095 JAS095 is offline help with control button code Windows 10 help with control button code Office 2021
Novice
help with control button code
 
Join Date: Aug 2023
Posts: 4
JAS095 is on a distinguished road
Default help with control button code

Hi firstly I am not a coder and am attempting this using you and the web as my guide and way of learning so will be very appreciative of any help people are able to give.

I have a control button that at this point sends an email with a word document attached but I want it to send it as the body text of the email without the button included and is that is not possible as a PDF attachment.

thanks for your assistance in advance.

here is the code that I am using.



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 = "Non-Negative DAS Reprt"

.Body = "Plaese see attached documet for details of Non-Negative DAS result"

.To = "sdgmnurse@anglogoldashanti.com"

.Importance = olImportanceNormal

.Attachments.Add xDoc.FullName

.Display

End With

Set xDoc = Nothing

Set xEmail = Nothing

Set xOutlookObj = Nothing

Application.ScreenUpdating = True

End Sub
Reply With Quote
  #2  
Old 08-28-2023, 05:19 PM
Guessed's Avatar
Guessed Guessed is offline help with control button code Windows 10 help with control button code Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Have a look at this code
Send Word document as email body - Simple Excel VBA which shows how to provide formatted text in the body of the email.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-28-2023, 06:27 PM
JAS095 JAS095 is offline help with control button code Windows 10 help with control button code Office 2021
Novice
help with control button code
 
Join Date: Aug 2023
Posts: 4
JAS095 is on a distinguished road
Default thanks but did seem to work

thanks I have tried replacing the code with the code supplied in the link putting in the email address ect but when i hit the control button it does not work (nothing happens)

Last edited by JAS095; 08-28-2023 at 06:46 PM. Reason: sent twice
Reply With Quote
  #4  
Old 08-28-2023, 06:43 PM
JAS095 JAS095 is offline help with control button code Windows 10 help with control button code Office 2021
Novice
help with control button code
 
Join Date: Aug 2023
Posts: 4
JAS095 is on a distinguished road
Default

thanks I have tried replacing the code with the code supplied in the link putting in the email address ect but when i hit the control button it does not work (nothing happens)
Reply With Quote
  #5  
Old 08-28-2023, 08:24 PM
Guessed's Avatar
Guessed Guessed is offline help with control button code Windows 10 help with control button code Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Can you show me the code after you adapted from that source? You already had the document open so your code would need to take that into account and wouldn't need to open the document again.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #6  
Old 08-28-2023, 11:12 PM
gmayor's Avatar
gmayor gmayor is offline help with control button code Windows 10 help with control button code Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The obvious issue in your code is that you have used Outlook commands rather than their numeric equivalents. See attached.
Attached Files
File Type: docm Example Code.docm (23.7 KB, 5 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Row with Content control using Command Button baes10 Word VBA 0 12-13-2017 11:30 AM
Command button shortcut Control + D baes10 Word VBA 1 12-11-2017 01:14 AM
ActiveX control button text keeps getting smaller ondertar Excel Programming 1 09-29-2015 05:38 AM
Prevent ActiveX Button Control from Deleted screech Word 0 06-24-2014 07:29 AM
Option Button ( ACtive X Control ) aligahk06 Excel 0 11-03-2009 06:36 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:39 AM.


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