Place graphic in a table cell

Q

quartz

I am using Office 2003 on Windows XP.

Is there a way to place a graphical object inside a table cell and lock it
there so it can't move? Better yet, can you snap the edges of the graphic to
the gridlines or borders in the table?

If this is possible either in VBA or conventional settings, could someone
please explain how to do it and/or provide some example code?

Thanks much in advance for your assistance.
 
D

Doug Robbins

Dim myrange as Range
Set myrange = ActiveDocument.Tables(1).Cell(1,1).Range
myrange.InlineShapes.AddPicture FileName:="[path\filename]"




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jay Freedman

To expand on this just a bit, if you're doing this without a macro, there
are a couple of settings to check.

- On the Table menu, select Autofit > Fixed Column Width. That will force
the picture to take the size of the table cell instead of the other way
around.
- On the Tools > Options > Edit dialog, set the "Insert/paste pictures as"
dropdown to "In line with text". Then a picture that you paste in or get
with Insert > Picture > From File will automatically become inline instead
of floating, so it's locked into the cell.

When you're doing this in code, you need to set
AutoFitBehavior=wdAutoFitFixed for the table, as the equivalent of the Fixed
Column Width setting. Calling InlineShapes.AddPicture instead of
Shapes.AddPicture takes care of the inline setting.

--
Regards,
Jay Freedman
Microsoft Word MVP

Doug said:
Dim myrange as Range
Set myrange = ActiveDocument.Tables(1).Cell(1,1).Range
myrange.InlineShapes.AddPicture FileName:="[path\filename]"





Doug Robbins - Word MVP
quartz said:
I am using Office 2003 on Windows XP.

Is there a way to place a graphical object inside a table cell and
lock it there so it can't move? Better yet, can you snap the edges
of the graphic to
the gridlines or borders in the table?

If this is possible either in VBA or conventional settings, could
someone please explain how to do it and/or provide some example code?

Thanks much in advance for your assistance.
 
Q

quartz

Jay, thanks for your exanding on this topic. This will help me a lot!

Jay Freedman said:
To expand on this just a bit, if you're doing this without a macro, there
are a couple of settings to check.

- On the Table menu, select Autofit > Fixed Column Width. That will force
the picture to take the size of the table cell instead of the other way
around.
- On the Tools > Options > Edit dialog, set the "Insert/paste pictures as"
dropdown to "In line with text". Then a picture that you paste in or get
with Insert > Picture > From File will automatically become inline instead
of floating, so it's locked into the cell.

When you're doing this in code, you need to set
AutoFitBehavior=wdAutoFitFixed for the table, as the equivalent of the Fixed
Column Width setting. Calling InlineShapes.AddPicture instead of
Shapes.AddPicture takes care of the inline setting.

--
Regards,
Jay Freedman
Microsoft Word MVP

Doug said:
Dim myrange as Range
Set myrange = ActiveDocument.Tables(1).Cell(1,1).Range
myrange.InlineShapes.AddPicture FileName:="[path\filename]"





Doug Robbins - Word MVP
quartz said:
I am using Office 2003 on Windows XP.

Is there a way to place a graphical object inside a table cell and
lock it there so it can't move? Better yet, can you snap the edges
of the graphic to
the gridlines or borders in the table?

If this is possible either in VBA or conventional settings, could
someone please explain how to do it and/or provide some example code?

Thanks much in advance for your assistance.
 

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