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 / July 2007

Tip: Looking for answers? Try searching our database.

InlineShapes Absolute Position in document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Mathewson - 23 Jul 2007 23:00 GMT
Hello all,

I'm trying to convert some object images to Inlineshapes images in Word
20007 but I can't seem to find the properties to set the TOP /LEFT position
of the picture.  Anyone have ideas?  I found using Shape() doesn’t work..I
need to work with the InlineShapes which doesn’t seem to have the needed
properties.

Thanks for any help

Jeff.
Jay Freedman - 24 Jul 2007 03:13 GMT
InlineShapes don't have Top and Left properties precisely because
their position is determined by where they fall within the text --
exactly as if they were simply a big character.

If you need an exact position on the page, you _must_ use a Shape
object. What about a Shape "doesn't work"?

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Hello all,
>
[quoted text clipped - 7 lines]
>
>Jeff.
Jeff Mathewson - 24 Jul 2007 22:22 GMT
Thanks for you reply,

The problem that I'm having is when I convert the image object to a shape
object the Shape Object floots over the text.  And if I convert the Shape
Object so I can place it anywhere within a page, I noted that the Shape
Object turns into a InlineShape Object or at least that's what VBA thinks it
is???  So I'm hoping there is some way to set the location of the picture on
the page using VBA without the use of the mouse to drag it. :)

Thanks for any help you can give.

Jeff.

> InlineShapes don't have Top and Left properties precisely because
> their position is determined by where they fall within the text --
[quoted text clipped - 21 lines]
> >
> >Jeff.
Jay Freedman - 25 Jul 2007 03:58 GMT
The key to placing a Shape object precisely is to define its Anchor,
which is a Range object within the text. Then the Top and Left
properties are measured from that anchor point. If you fail to define
an anchor, VBA assumes you meant to place it at the top left corner of
the page, which is almost never correct.

Here's some sample code for placing a Shape 0.5 inch to the right and
0.1 inch above the current cursor location, and then sizing the Shape
and setting its wrapping to Square:

Sub demo()
   Dim oShp As Shape
   Dim oRg As Range
   
   Set oRg = Selection.Range
   oRg.Collapse wdCollapseStart
   
   Set oShp = ActiveDocument.Shapes.AddPicture( _
       FileName:="C:\bunnycakes.jpg", _
       LinkToFile:=False, _
       SaveWithDocument:=True, _
       Left:=InchesToPoints(0.5), _
       Top:=InchesToPoints(-0.1), _
       Anchor:=oRg)
       ' Left and Top are relative to the anchor
   
   With oShp
       .WrapFormat.Type = wdWrapSquare
       .LockAspectRatio = msoTrue
       .Width = InchesToPoints(2.5)
   End With
End Sub

Variations on this would be to define the range differently, to make
the Shape by calling the .ConvertToShape method of an existing
InlineShape, resizing the .Width and .Height separately, etc.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Thanks for you reply,
>
[quoted text clipped - 34 lines]
>> >
>> >Jeff.
 
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.