JohnT
11-16-2006, 09:59 AM
Hi,
Working in Word 2003.
I have a table of 8 columns and 2 rows.
The attached macro is designed to place an image in the odd numbered cells (i.e. 1,3,5,7 etc.) (later code then scales the image to fit the cell).
When selecting a graphic file (jpeg, usualy) I give the user the oportunity to remove the existing graphic, if one is not required.
The problem is the first time the following code runs it does not place the graphic, the second time it runs it does.
The only thought I have is that the anchor property is incorrect, but not sure why.
This is my first post and I do hope I have given enough information.
Regards
John
'Move selection point to start of cell 1,1
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Collapse wdCollapseStart
'Add the picture to all cells
For cellcount = 1 To 8
ActiveDocument.Shapes.AddPicture FileName:=PicName, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=-90, _
Top:=165, _
Anchor:=Selection.Range
'If at end of table do not try to select next cell
If cellcount <> 8 Then
Selection.MoveRight unit:=wdCell, Count:=2
Selection.Collapse wdCollapseStart
End If
Next
Working in Word 2003.
I have a table of 8 columns and 2 rows.
The attached macro is designed to place an image in the odd numbered cells (i.e. 1,3,5,7 etc.) (later code then scales the image to fit the cell).
When selecting a graphic file (jpeg, usualy) I give the user the oportunity to remove the existing graphic, if one is not required.
The problem is the first time the following code runs it does not place the graphic, the second time it runs it does.
The only thought I have is that the anchor property is incorrect, but not sure why.
This is my first post and I do hope I have given enough information.
Regards
John
'Move selection point to start of cell 1,1
ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Collapse wdCollapseStart
'Add the picture to all cells
For cellcount = 1 To 8
ActiveDocument.Shapes.AddPicture FileName:=PicName, _
LinkToFile:=False, _
SaveWithDocument:=True, _
Left:=-90, _
Top:=165, _
Anchor:=Selection.Range
'If at end of table do not try to select next cell
If cellcount <> 8 Then
Selection.MoveRight unit:=wdCell, Count:=2
Selection.Collapse wdCollapseStart
End If
Next