Microsoft Office Tutorials and References
In Depth Information
Forms: Placing a Picture in a Protected Form
'Display the Insert picture dialog box¶
'But don't let it execute¶
Set dlg = Dialogs(wdDialogInsertPicture)¶
'If cancel was not clicked¶
If dlg.Display <> 0 Then¶
'Make sure the target exists¶
If doc.Bookmarks.Exists(BookmarkTarget) Then¶
Set rng = doc.Bookmarks(BookmarkTarget).Range¶
'Delete any pictures currently in the bookmark¶
If rng.InlineShapes.Count > 0 Then¶
rng.InlineShapes(1).Delete¶
End If¶
'Insert the picture into the bookmark¶
Set ils = doc.InlineShapes.AddPicture( _¶
FileName:=dlg.Name, LinkToFile:=False, _¶
SaveWithDocument:=True, Range:=rng)¶
'Recreate the bookmark around the picture¶
doc.Bookmarks.Add Name:=BookmarkTarget, _¶
Range:=ils.Range¶
Else¶
'MsgBox "Target for picture not found"¶
End If¶
End If¶
doc.Protect Type:=wdAllowOnlyFormFields, _¶
NoReset:=True, password:=password¶
End Sub¶
Wrd
Set the constant values:
Password
If the form is protected with a password, supply it here.
The macro must temporarily unprotect the form in
order to delete the row. If no password has been
assigned, use a zero-length string ("").
¾
bookmarkTarget
The name of the bookmark marking the target position
for the picture being inserted.
¾
The macro runs from a toolbar that displays when a document is created using
the template.
Set up the form. Insert a bookmark at each location where the user should be
able to insert a picture.
Search JabSto ::




Custom Search