F
Frankie
Hi,
I am trying to copy a chart from excel into a word document, at a
position specified by a bookmark. I also want the float over text to be
deactivated. My rather poor attempt at that was:
Sub FlushGraphs()
Dim WordObj As Word.Application, WordDoc As Word.Template
Set WordObj = CreateObject("Word.Application")
Sourcedir = ThisWorkbook.Path
FileName = Sourcedir & "\myworddocument.doc"
WordObj.Documents.Open (FileName)
WordObj.Visible = True
With Excel.Application
.ActiveSheet.ChartObjects("Chart 2").Activate
.ActiveChart.ChartArea.Select
.ActiveChart.ChartArea.Copy
End With
With WordObj
rRange = .ActiveDocument.Bookmarks(1).Range
rRange.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
.ActiveDocument.Bookmarks(2).Range.Text = "HELLO" ' to satisfy
myself the bookmarks work
End With
' Set WordDoc = Nothing
' Set WordObj = Nothing
' WordObj.Documents.Save
' WordObj.Documents.Close
' WordObj.Quit
End Sub
I am trying to copy a chart from excel into a word document, at a
position specified by a bookmark. I also want the float over text to be
deactivated. My rather poor attempt at that was:
Sub FlushGraphs()
Dim WordObj As Word.Application, WordDoc As Word.Template
Set WordObj = CreateObject("Word.Application")
Sourcedir = ThisWorkbook.Path
FileName = Sourcedir & "\myworddocument.doc"
WordObj.Documents.Open (FileName)
WordObj.Visible = True
With Excel.Application
.ActiveSheet.ChartObjects("Chart 2").Activate
.ActiveChart.ChartArea.Select
.ActiveChart.ChartArea.Copy
End With
With WordObj
rRange = .ActiveDocument.Bookmarks(1).Range
rRange.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdInLine, DisplayAsIcon:=False
.ActiveDocument.Bookmarks(2).Range.Text = "HELLO" ' to satisfy
myself the bookmarks work
End With
' Set WordDoc = Nothing
' Set WordObj = Nothing
' WordObj.Documents.Save
' WordObj.Documents.Close
' WordObj.Quit
End Sub