PC Review


Reply
Thread Tools Rate Thread

copy excel chart to word - format problem

 
 
=?Utf-8?B?U2FtaXJrYw==?=
Guest
Posts: n/a
 
      11th Apr 2007
Dear all,
I am trying to paste excel chart to word (as picture) using VBA. I have one
chart, I change the country name and the year and the chart changes. I then
copy the chart to a Word file (all using Macro). I want to paste chart, one
after another in two columns. The first chart pastes well but (it fits to the
page format), however, the subsequent charts are bigger and do not fit.
Please help. The following is the macro that I use.

Sub graph_20_65_for()
z = "graphs"

Sub Exporter_graph()

' Tools ... References ... Word

Dim MyWord As Word.Application
Dim MyDoc As Word.Document
Dim MyExcel As Excel.Workbook
Dim MyPath, exlMyFileName, wrdMyFileName As String
Dim MyBox
z = "graphs"
MyPath = ActiveWorkbook.Path
exlMyFileName = ActiveWorkbook.Name


Set MyWord = GetObject(, "Word.Application")
Set MyExcel = GetObject(MyPath & "\" & exlMyFileName)
Set MyDoc = MyWord.Documents("graph_projection.doc")
Set MyDoc = MyWord.ActiveDocument

For yr = 1 To 6
MyExcel.Sheets(z).Range("b2").Value = 2000 + 10 * (yr - 1)

MyExcel.ActiveSheet.ChartObjects("Chart 9").Activate
ActiveChart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture


MyWord.Visible = True

'Copying and pasting

MyDoc.ActiveWindow.Selection.Collapse Direction:=wdCollapseEnd

MyWord.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False


MyExcel.Sheets(z).Range("b2").Activate

Next yr


Set MyWord = Nothing
Set MyExcel = Nothing
Set MyDoc = Nothing


End Sub
For n_country = 1 To 120
Sheets(z).Range("a2").Value = _
Sheets(z).Range("a15").Offset(n_country - 1, 0).Value

ind_baseline = Sheets("data_edu_prop").Range("n26").Value
If ind_baseline = 1 Then GoTo samir:

d = Sheets(z).Range("b15").Offset(n_country - 1, 0).Value


Sheets(z).ChartObjects("Chart 9").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = -d
.MaximumScale = d
End With

Call Exporter_graph

samir:
Next n_country
End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to copy Excel chart to Word so I can move it around in Word NonTechie Microsoft Word Document Management 7 11th Oct 2009 05:53 PM
Copy Chart from Excel to Word using VBA =?Utf-8?B?Sm9uYXRoYW4gQWxsZW4=?= Microsoft Excel Programming 6 8th Mar 2009 02:02 AM
copy an excel chart to word =?Utf-8?B?T3lWZXktQ29Dbw==?= Microsoft Excel Charting 1 26th Jul 2007 03:47 PM
Copy Paste Chart format in Excel 2003 using VB.NET =?Utf-8?B?TWFjQW5keQ==?= Microsoft Excel Charting 1 28th May 2007 02:14 PM
I pasted chart from excel to word, format in word changed??? =?Utf-8?B?S2Fua3k=?= Microsoft Word Document Management 1 28th Apr 2006 10:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:21 AM.