sizing a chart in Word that was created in Excel VBA

A

Ariel

I am copying a chart that was created in Excel, pasting into a Word document,
and then resizing it so that I can redo this loop to place a second chart
next to it.

I am having problem with the resizing code (I haven't even tackled the
side-by-side issue yet). Any help is appreciated!



WordApp.Selection.PasteAndFormat (wdChartPicture)


With WordApp.ActiveDocument
.InlineShapes(1).Fill.Visible = msoFalse
.InlineShapes(1).Fill.Solid
.InlineShapes(1).Fill.Transparency = 0#
.InlineShapes(1).Line.Weight = 0.75
.InlineShapes(1).Line.Transparency = 0#
.InlineShapes(1).Line.Visible = msoFalse
.InlineShapes(1).LockAspectRatio = msoTrue
.InlineShapes(1).Height = 115.2
.InlineShapes(1).Width = 220.3
.InlineShapes(1).PictureFormat.Brightness = 0.5
.InlineShapes(1).PictureFormat.Contrast = 0.5
.InlineShapes(1).PictureFormat.ColorType = msoPictureAutomatic
.InlineShapes(1).PictureFormat.CropLeft = 0#
.InlineShapes(1).PictureFormat.CropRight = 0#
.InlineShapes(1).PictureFormat.CropTop = 0#
.InlineShapes(1).PictureFormat.CropBottom = 0#
.InlineShapes(1).Left = 0#
.InlineShapes(1).Top = 0#
End With
 
J

Jon Peltier

1. Make the Excel chart the right size before you copy it.
2. Create a table in Word to hold the charts. This makes the side by side
easier to achieve.
3. Remove all the default settings from your recorded code. If all you did
was resize the chart, then these are the only relevant lines:

With WordApp.ActiveDocument
.InlineShapes(1).Height = 115.2
.InlineShapes(1).Width = 220.3
End With

4. You might find some useful clues on this page:

http://peltiertech.com/Excel/XL_PPT.html

- Jon
 
A

Ariel

Jon, it worked perfectly! Thanks a bunch.

Ariel

Jon Peltier said:
1. Make the Excel chart the right size before you copy it.
2. Create a table in Word to hold the charts. This makes the side by side
easier to achieve.
3. Remove all the default settings from your recorded code. If all you did
was resize the chart, then these are the only relevant lines:

With WordApp.ActiveDocument
.InlineShapes(1).Height = 115.2
.InlineShapes(1).Width = 220.3
End With

4. You might find some useful clues on this page:

http://peltiertech.com/Excel/XL_PPT.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top