Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Sizing pasted inlineshape

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dave.cuthill@computalog.com - 10 Jun 2005 07:07 GMT
I am creating a chart in excel and then pasting it into word as an
inlineshape but the default size is incorrect. How do I size the object
at the time of pasting - ie. does inlineshapes(1) necessarily select
the pasted object or does it select the first inlineshape? How do I
make sure I am resizing the pasted object?

Here is an extraction ...

Set oWordDoc = ActiveDocument
TabCnt = oWordDoc.Tables.Count

Set Rng = ActiveDocument.Tables(1).Range
Rng.Collapse wdCollapseEnd
Rng.InsertAfter "" & vbCrLf
Rng.Collapse wdCollapseEnd
BMName = "BarChart"
ActiveDocument.Bookmarks.Add Name:=BMName, Range:=Rng

other stuff ...

oGraphChart.ChartArea.Copy

Rng.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, Placement _
   :=wdInLine, DisplayAsIcon:=False
Jonathan West - 10 Jun 2005 13:00 GMT
>I am creating a chart in excel and then pasting it into word as an
> inlineshape but the default size is incorrect. How do I size the object
> at the time of pasting - ie. does inlineshapes(1) necessarily select
> the pasted object or does it select the first inlineshape? How do I
> make sure I am resizing the pasted object?

You do this by assigning a range object variable to the pasted Range, and
then manipulating the first InlineShape object within that range.

> Here is an extraction ...
>
[quoted text clipped - 14 lines]
> Rng.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, Placement _
>    :=wdInLine, DisplayAsIcon:=False

Replace the last line with this

Dim PasteRange as Range
Set PasteRange = Rng.PasteSpecial(Link:=False, DataType:=wdPasteOLEObject, _
   Placement:=wdInLine, DisplayAsIcon:=False)

With PasteRange.InlineShapes(1)
 'add your code here to manipulate the shape
End With

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

dave.cuthill@computalog.com - 10 Jun 2005 20:51 GMT
I am unable to get your suggestion to work. The object is pasted but
any attempts to resize the object do not work.
Cindy M  -WordMVP- - 11 Jun 2005 16:44 GMT
> I am creating a chart in excel and then pasting it into word as an
> inlineshape but the default size is incorrect. How do I size the object
> at the time of pasting - ie. does inlineshapes(1) necessarily select
> the pasted object or does it select the first inlineshape? How do I
> make sure I am resizing the pasted object?

As I recall, when you paste the selection (or range) always ends up to
the left of the pasted object (actually a field of one sort or another).
So best would be to extend the range (to the end of the paragraph, for
example) then pick up the first inline shape in that range.

Note: Often, it's better to have an Excel chart on a separate page in
Excel, sized to the correct size you need in Word. That's the best way to
avoid distortions and similar problems.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
dave.cuthill@computalog.com - 13 Jun 2005 15:51 GMT
Thanks Cindy extending the range did the trick. I tried resizing the
chart in Excel but it seemed to have no effect on what showed up in
Word.

David
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.