I'm creating Outlook email from Excel (Office 2013). I want to paste one category of cells (C3: S 52) into e-mail as a category.
I have the code given below, where I am going wrong
sub-button193_Click () '' Button193_Click macro '' ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 range ?. ("C3: S52") Select Selection.Copy End Sub Sub CreateMail () dim objOutlook Object dim objMail as the object dim RngTo Range range as dim rngSubject range as Range RodyBody Set the range as the slow rngAttach objOutlook = SetObject ("Outlook.Application") set to ActiveSheet with objMail = objOutlook.CreateItem (0) set rngTo = .RangeSubject = Range ("E55") set. Range ("E56") Set rngBody = .Range ("E57") with the end to objMail. Exposure = rngTo.Value. Subject = rngSubject.Value .body = RngBody.Value.Display instead of '. Display, you can use. Send email to send _or_ To save a copy to the draft folder, save with the end set to objOutlook = None set objMail = None set rngTo = None set rngSubject = None set rngBody = None set RngAttach = None End Sub Sub Button (235_Click) Select '' Button 235_Click Macro '' ActiveWindow.ScrollColumn = 2 ActiveWindow.ScrollColumn = 1 Range ("A1: M27") Selection.Copy End Sub Sub RunThemAll () Application. Run "Button193_Click" Application.Run "CreateMail" End Sub
This is a successful example, tested in Office 2010:
![]()
Set range range range range like r = Range ("B2: D5") r.Copy 'Open a new mail item dim outlookApp Setup Outlook.Application outlookApp = CreateObject (such as "Outlook.Application") Dim OutMail Outlook.MailItem set outMail = outlookApp.CreateItem (OlMailItem) Get your post editor go outMail.Display the slow wordDoc Word.Document set wordDoc = outMail.GetInspector.WordEditor 'as picture wordDoc.Range.Past EAndFormat wdChartPicture to paste as 'table' wordDoc.Range.PasteExcelTable as LinkedToExcel: = false, WordFormatting: = false, RTF: = incorrect results :
![]()
code above In I used the initial bond to reach the fullness; To use this code you need to set the context of Microsoft Outlook and Microsoft Word Object Library: P>
![]()
Alternatively, you can forget about contexts and use late binding, all Outlook and Word objects as
objects asInstead of declaring as Outlook. Apli Karanandas Word. Documentetc.
Apparently you are having trouble applying the above; In the e-mail message, instead of a picture, the range has been pasted. I have no such explanation why this will happen.
An option is to paste in Excel as an image, and then cut and paste that image into your email:
'interest Set the boundary in the form of R. r = Paste the copy range ("B2: D5") in the r.Copy 'sheet as the picture and immediately set the dim p cut image P = ActiveSheet.Pictures.Paste p.Cut As' a new mail item dim outlookApp Setup Outlook.Application outlookApp = CreateObject ("Outlook.Application") Dim OutMail Outlook.MailItem set outMail = outlookApp.CreateItem In the Form Open (olMailItem) 'at his post as editor outMail.Display dim wordDoc words. Document set by wordDoc = outMail.GetInspector.WordEditor 'Paste Image wordDoc.Range.Pasteas explained by, there is also the option of using
PasteSpecialInstead ofPasteAndFormatorpaste...< P> ... but for some reason, the resultant image is not render, as well as R, see what kind of the bottom table is blurred:wordDoc.Range.PasteSpecial ,,,, wdPasteBitmap
No comments:
Post a Comment