Ok.
I have a document formatted with a tables and textbox and protected, the
first textbox calls a userform. The userform collects data from the user and
his selections with textbox, combobox and checkbox, serch in the sql server
and calculate any valors. Last, the userform transfers inserted, calculated
and recollected data to the document, my problem is transfer any images
(with vba coding) to the formated cells of the tables without lose the size
of cells. I like the autosize the images not autosize the cells!
i use the next code for transfer images from userform to document, where
"signature" is a bookmark entry in the desired cell:
ActiveDocument.Bookmarks("signature").Select
Selection.InlineShapes.AddPicture FileName:="C:\PROJECT\TEST1\IMAgES\" &
TEST1.Fields("op_sign").Value & ".jpg", LinkToFile:=False,
SaveWithDocument:=True
Thanks for your comments!
Sam
>>Hi!
>>
[quoted text clipped - 30 lines]
> Email cannot be acknowledged; please post all follow-ups to the newsgroup
> so all may benefit.
Jay Freedman - 08 Oct 2007 19:04 GMT
This is a little more complicated than you might think at first. Not a lot,
just a little.
The first problem to work around is that you can't insert a picture at a
bookmark in a protected document while it's still protected. The code will
have to unprotect the document, insert the picture, and finally reprotect
the document (using an optional parameter of the .Protect method to prevent
all the fields from resetting to their default values).
The second thing isn't a problem, but a simplification. Since you'll be
using a table (with fixed column width) to hold the picture, you don't need
a bookmark to know where to put the picture. Also, it's poor practice to
move the insertion point and use the Selection object to insert the picture;
you can directly address the particular cell of the table without selecting
it.
As an example, add this to whatever other code is in your command button's
Click procedure:
Const path = "C:\PROJECT\TEST1\IMAGES\"
Dim oTbl As Table
Dim oCel As Cell
' unprotect the form if needed
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
End If
' modify the next two lines if the table isn't the
' first one in the document, or if the signature
' goes in a different cell of the table
Set oTbl = ActiveDocument.Tables(1)
Set oCel = oTbl.Cell(1, 2)
' note the Range argument...
ActiveDocument.InlineShapes.AddPicture _
FileName:=path & TEST1.Fields("op_sign").Value & _
".jpg", LinkToFile:=False, SaveWithDocument:=True, _
Range:=oCel.Range
' reprotect without resetting the fields to default values
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True

Signature
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.
> Ok.
>
[quoted text clipped - 52 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.