panks_r
08-01-2009, 02:19 PM
Hi,
I am writing a program to generate word documents which contain data pulled in from excel along with some charts. I am using PasteSpecial function to paste the charts from excel to word. But image is currently overwriting any text, I might have in the document. I tried using both the wdCollaspeEnd and wdCollapseStart functions but it did not work for me. I have pasted the code snipet below.
With wrdDoc
Dim ch As ChartObject
Set ch = Worksheets("Permanent Workforce Chart").ChartObjects(1)
ch.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'Custom Text
.Content.InsertAfter "Report 2009"
.Content.InsertParagraphAfter
.Content.InsertAfter strCompName
.Content.InsertParagraphAfter
.Content.Collapse (WdCollapseDirection.wdCollapseEnd)
.Content.PasteSpecial Placement:=WdOLEPlacement.wdInLine, DataType:=WdPasteDataType.wdPasteBitmap
.SaveAs ("<doc name>")
.Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
Can someone please help me on this?
-Thanks
I am writing a program to generate word documents which contain data pulled in from excel along with some charts. I am using PasteSpecial function to paste the charts from excel to word. But image is currently overwriting any text, I might have in the document. I tried using both the wdCollaspeEnd and wdCollapseStart functions but it did not work for me. I have pasted the code snipet below.
With wrdDoc
Dim ch As ChartObject
Set ch = Worksheets("Permanent Workforce Chart").ChartObjects(1)
ch.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
'Custom Text
.Content.InsertAfter "Report 2009"
.Content.InsertParagraphAfter
.Content.InsertAfter strCompName
.Content.InsertParagraphAfter
.Content.Collapse (WdCollapseDirection.wdCollapseEnd)
.Content.PasteSpecial Placement:=WdOLEPlacement.wdInLine, DataType:=WdPasteDataType.wdPasteBitmap
.SaveAs ("<doc name>")
.Close ' close the document
End With
wrdApp.Quit ' close the Word application
Set wrdDoc = Nothing
Set wrdApp = Nothing
Can someone please help me on this?
-Thanks