Positioning an inline shape

B

Bo Hansson

I want to insert an inline shape into a table cell and then add text below
the shape.
In Word 2003 I'm using the following code (which works fine):

.Move Unit:=wdCell, Count:=1
.Expand wdCell
.InlineShapes.AddPicture FileName:=<path> & "Picture.bmp"
.InsertAfter vbCrLf
.InsertAfter "Text"


However, when using the same code in Word 2000, it does not give the desired
result.
The shape then seems to choose its own position within the cell!

Please, tell me what to do.

/BosseH
 
C

Cindy M -WordMVP-

Hi Bo,
I want to insert an inline shape into a table cell and then add text below
the shape.
In Word 2003 I'm using the following code (which works fine):

.Move Unit:=wdCell, Count:=1
.Expand wdCell
.InlineShapes.AddPicture FileName:=<path> & "Picture.bmp"
.InsertAfter vbCrLf
.InsertAfter "Text"


However, when using the same code in Word 2000, it does not give the desired
result.
The shape then seems to choose its own position within the cell!
Please describe "seems to choose its own position within the cell".

Apparently, you're working with the Selection object (you really should copy
the ENTIRE code context!). It might be more predictable to work with a range
object. And I'd probably set an object variable to the InlineShape so that I
can get it's range. Maybe something like this:

Dim ils as Word.InlineShape
Dim rng as Word.Range

Set ils = .InlineShapes.AddPicture FileName:=<path> & "Picture.bmp"
Set rng = ils.Range
rng.Collapse wdCollapseEnd
rng.Text = vbCR & "Text"

Please note that Word does not use vbCRLF, and that this can, under
circumstances, give an "unexpected result".

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 :)
 

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