[RESOLVED] how can I add a Picture into table? (WORD)
hi, all!
I have:
VB Code:
'I've got it from a recorded macro. It works:
Selection.InlineShapes.AddPicture FileName:= _
"C:\MyPicture.jpg", LinkToFile:=False, SaveWithDocument :=True
'AND REFERENCE TO MY TableSTRING:
Set String1 = Table1.Rows.Add
But how can I add Picture into string without "Selection."
I've tried:
String1.Cells(2).Range.AddPicture...
& String1.Cells(2).Range.InlineShapes.AddPicture...
it doesn't work:(
Help me please!
kind regards,
Baloo.
Re: how can I add a Picture into table? (WORD)
Here is the problem:
Quote:
Set String1 = Table1.Rows.Add
Here you need to mention which table you are going to work. It may be the table where the cursor located or may be the table no. in the active document. So, it popups the error.
Here is the code for you.
VB Code:
Dim String1 As Range
'table where the cursor located
Set String1 = Selection.Tables(1).Range
'the 1st table of the current document
'Set String1 = ActiveDocument.Tables(1).Range
String1.Tables(1).Cell(1, 2).Range.InlineShapes.AddPicture filename:= _
"C:\Clip.gif", LinkToFile:=False, SaveWithDocument:=True
'String1.Tables(1).Cell(1, 2).Range.InlineShapes.AddPicture filename:= _
"C:\Clip.gif", LinkToFile:=False, SaveWithDocument:=True
Re: how can I add a Picture into table? (WORD)
it works!!! :D
CSSRIRAMAN,THANKS A LOT :thumb:
kind regards,
Baloo.