A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Paste an Excel Chart in an Outlook Body



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 26th 06, 11:55 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 1
Default Paste an Excel Chart in an Outlook Body

I am trying to paste an excel shart in the body of an outlook message.
I already managed to do this through exporting the chart and then
importing, but the chart loses a lot of quality so I am trying to find
a way to paste the chart through the clipboard.

the only thing missing in my code would be the procedure to paste the
chart that is already on the clipboard. here's what I have:

Sub SendEmail()

Dim theApp, theNameSpace, theMailItem, myAttachment, Msg


'create a new Outlook Application Object,
'direct it to the proper NameSpace,
'create a new Mail Item and set the attachments collection
Set theApp = CreateObject("Outlook.Application")
Set theNameSpace = theApp.GetNamespace("MAPI")
Set theMailItem = theApp.CreateItem(0)
Set myAttachment = theMailItem.Attachments
theMailItem.Display


' campo mensagem '
Workbooks.Open "Test.xls"
Sheets("Sheet1").Select
ActiveSheet.ChartObjects("Grafico").Activate
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture
Sheets("Sheet1").Cells(1, 1).Select

'add recipients to MailItem
theMailItem.Recipients.Add "
theMailItem.subject = "Anything"
theMailItem.Body = Msg

theMailItem.Send
theNameSpace.Logoff


End Sub


I found the code below on this same newsgroup that supposedly would do
the job, but it is not working. Does anyone know why?

Sub Pastebody()
Set tmpBody =
Item.GetInspector.ModifiedFormPages("Message").Con trols("Message")
tmpBody.SetFocus
Item.GetInspector.CommandBars.Item("Menu
Bar").Controls("Edit").Controls("Paste").Execute
End Sub

Thanks

Ads
  #2  
Old September 27th 06, 06:39 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Paste an Excel Chart in an Outlook Body

Am 26 Sep 2006 14:55:53 -0700 schrieb :

The problem is that with the Outlook object model you canīt set the focus to
the body window. With Redemption (
www.dimastr.com) that works. Once you know
that the body has the focus you can get the Insert button from the
commandbar (ID=22) and call its Execute method.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


I am trying to paste an excel shart in the body of an outlook message.
I already managed to do this through exporting the chart and then
importing, but the chart loses a lot of quality so I am trying to find
a way to paste the chart through the clipboard.

the only thing missing in my code would be the procedure to paste the
chart that is already on the clipboard. here's what I have:

Sub SendEmail()

Dim theApp, theNameSpace, theMailItem, myAttachment, Msg


'create a new Outlook Application Object,
'direct it to the proper NameSpace,
'create a new Mail Item and set the attachments collection
Set theApp = CreateObject("Outlook.Application")
Set theNameSpace = theApp.GetNamespace("MAPI")
Set theMailItem = theApp.CreateItem(0)
Set myAttachment = theMailItem.Attachments
theMailItem.Display


' campo mensagem '
Workbooks.Open "Test.xls"
Sheets("Sheet1").Select
ActiveSheet.ChartObjects("Grafico").Activate
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen,
Format:=xlPicture
Sheets("Sheet1").Cells(1, 1).Select

'add recipients to MailItem
theMailItem.Recipients.Add "
theMailItem.subject = "Anything"
theMailItem.Body = Msg

theMailItem.Send
theNameSpace.Logoff


End Sub


I found the code below on this same newsgroup that supposedly would do
the job, but it is not working. Does anyone know why?

Sub Pastebody()
Set tmpBody =
Item.GetInspector.ModifiedFormPages("Message").Con trols("Message")
tmpBody.SetFocus
Item.GetInspector.CommandBars.Item("Menu
Bar").Controls("Edit").Controls("Paste").Execute
End Sub

Thanks

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
comparison chart for OE vs Outlook vs ? Pamela G. Outlook Express 1 July 16th 06 01:54 AM
extracting mailitem.body text to Excel columns Junoon Outlook and VBA 3 April 20th 06 06:45 AM
Paste cells from Excel into message body goshute Outlook and VBA 1 March 29th 06 07:02 AM
Tough One - Update Pivot Chart in Access Report using VBA? jer99 Outlook and VBA 2 January 19th 06 11:29 PM


All times are GMT +1. The time now is 08:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2025 Outlook Banter.
The comments are property of their posters.