copy chart and paste into Word

teel73

Registered User.
Local time
Today, 03:15
Joined
Jun 26, 2007
Messages
205
Hopefully this is the right forum. From MS Access, I connect to Excel,
I copy a chart then I would like to paste the chart into a Word document.

I have been able to successfully connect and open both the Excel document and Word document from Access. I'm also successful with copying the Excel chart to the clipboard. Pasting into my Word document is where my code fails. Does anyone know where my error is. here is my code:

Code:
Dim oWordApp As Object
Dim oDoc As Object
 
'function that connects to Excel and open File
conExcelF (rptLoc & rptName)
 
Set oWordApp = CreateObject("Word.Application")
oWordApp.Visible = False

f = rptLoc & "TEST.docx"
Set oDoc = oWordApp.Documents.Open(f)
 
'ws is a function that selects the worksheet
ws("FY13TD_Audit").ChartObjects("Chart 3").Activate
ActiveChart.ChartArea.Copy
 
'here is where I select the bookmark in my word document
oDoc.Bookmarks("AuditChart").Range.Select
 
'here is where my code fails; trying to paste the chart
Selection.PasteAndFormat wdChartPicture

can anybody help me with this?
 
I think that you have also an error message. What this message say ?

An idea:
Run your code except the last line (that fail).
Switch to Word and start to record a new macro.
Press CTRL+V
Is the chart pasted ?

If YES, stop the macro recording and edit this macro, maybe this will give you new ideas.
 
I use the clipboard to paste graphs in Excel or Word.

I have a button with only one line of code

Me.[yourgraph].Action = acOLEcopy

In WORD I just do CTRL V.
When I only want a picture in stead of the OLE, I just copy the graph again, but then in WORD and paste it as picture

Ben
 
I think that you don't read very carefully my previous post.
Before to paste, start to record a macro.
Word will give you (I hope) the exact code to use.
 

Users who are viewing this thread

Back
Top Bottom