ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Copying charts from excel into word (https://www.excelbanter.com/excel-worksheet-functions/118643-copying-charts-excel-into-word.html)

anita

Copying charts from excel into word
 
Hi,

I would like to copy a chart from excel into word. I've tried to make a
macro see below, but it stops with:
" Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture". Could
somebody help me please?
Thanks in advance.
Anita

Sub Openfile()
Dim templateName As String
Dim arrGraphBookmarks As String
Set appWD = CreateObject("Word.Application")
dirnaam = "D:\"
templateName = "Layout rapport En.doc"
With appWD
.ChangeFileOpenDirectory dirnaam
.Documents.Open Filename:=templateName, ReadOnly:=True
.Visible = True
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize

End With
Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture
With appWD
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize
.Selection.Goto what:=wdGoToBookmark, Name:=CS_FS
.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdWrapSquare, DisplayAsIcon:=False
End With

End Sub


Gary''s Student

Copying charts from excel into word
 
I can't test this, but try to select the chart object before copying it.
--
Gary's Student


"anita" wrote:

Hi,

I would like to copy a chart from excel into word. I've tried to make a
macro see below, but it stops with:
" Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture". Could
somebody help me please?
Thanks in advance.
Anita

Sub Openfile()
Dim templateName As String
Dim arrGraphBookmarks As String
Set appWD = CreateObject("Word.Application")
dirnaam = "D:\"
templateName = "Layout rapport En.doc"
With appWD
.ChangeFileOpenDirectory dirnaam
.Documents.Open Filename:=templateName, ReadOnly:=True
.Visible = True
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize

End With
Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture
With appWD
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize
.Selection.Goto what:=wdGoToBookmark, Name:=CS_FS
.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdWrapSquare, DisplayAsIcon:=False
End With

End Sub



anita

Copying charts from excel into word
 
Thanks for the input, but unfortunately it doesn't work. Have you
perhaps got more suggestions?

Anita
Gary''s Student schreef:

I can't test this, but try to select the chart object before copying it.
--
Gary's Student


"anita" wrote:

Hi,

I would like to copy a chart from excel into word. I've tried to make a
macro see below, but it stops with:
" Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture". Could
somebody help me please?
Thanks in advance.
Anita

Sub Openfile()
Dim templateName As String
Dim arrGraphBookmarks As String
Set appWD = CreateObject("Word.Application")
dirnaam = "D:\"
templateName = "Layout rapport En.doc"
With appWD
.ChangeFileOpenDirectory dirnaam
.Documents.Open Filename:=templateName, ReadOnly:=True
.Visible = True
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize

End With
Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture
With appWD
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize
.Selection.Goto what:=wdGoToBookmark, Name:=CS_FS
.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdWrapSquare, DisplayAsIcon:=False
End With

End Sub




Gary''s Student

Copying charts from excel into word
 
This did work (at least the copy part)

Sub Macro1()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy
End Sub

I could not record the paste in Word part.
--
Gary's Student


"anita" wrote:

Thanks for the input, but unfortunately it doesn't work. Have you
perhaps got more suggestions?

Anita
Gary''s Student schreef:

I can't test this, but try to select the chart object before copying it.
--
Gary's Student


"anita" wrote:

Hi,

I would like to copy a chart from excel into word. I've tried to make a
macro see below, but it stops with:
" Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture". Could
somebody help me please?
Thanks in advance.
Anita

Sub Openfile()
Dim templateName As String
Dim arrGraphBookmarks As String
Set appWD = CreateObject("Word.Application")
dirnaam = "D:\"
templateName = "Layout rapport En.doc"
With appWD
.ChangeFileOpenDirectory dirnaam
.Documents.Open Filename:=templateName, ReadOnly:=True
.Visible = True
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize

End With
Worksheets("ReportFS").ChartObjects("CS_FS").CopyP icture
With appWD
.ActiveDocument.ActiveWindow.WindowState =
wdWindowStateMinimize
.Selection.Goto what:=wdGoToBookmark, Name:=CS_FS
.Selection.PasteSpecial Link:=False,
DataType:=wdPasteEnhancedMetafile, _
Placement:=wdWrapSquare, DisplayAsIcon:=False
End With

End Sub






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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com