Creating a form that will allow users to insert pictures

J

Jackie

I am creating a form in Office Word 2003 where I am putting in mostly Text
Form Fields. I also want the people filling in the form to be able to insert
photos. Once the document is secured the options for insert photos is not
available. I have also tried insert frame then securing but still does not
allow person filling in form ability to insert photo. How can this be done?
 
G

Graham Mayor

Assuming that you are supplying the form as a template and that you can be
sure that users will allow the macros it contains to run, then you can
provide a macro to insert a picture. Insert a table (you only need one cell)
and set the cell width to the fixed width that you wish the picture to
adopt. The height of the cell is less relevant, but set it to sufficient
height that inserting a picture will not upset your layout. Remove any
border from the cell.

If your form is already laid out as a table of with tables, you will need to
identify the table index of your new 'table'. The macro assumes the first
cell in Tables(1)
from the line Set oRng = oDoc.Tables(1).Cell(1, 1).Range. Change the cell
location if required. You can then run the macro from a toolbar button on a
custom toolbar in the template - at at a pinch on exit from a form field. -
http://www.gmayor.com/installing_macro.htm .

It is possible to set the start location for the picture folder to the
user's My Pictures folder, but it requires a lot more code. If you need to
do that contact me via my web site and I'll mail you the extra code.


Dim strFilePath As String
Dim oDoc As Document
Dim oRng As Range
Set Dlg = Application.FileDialog(msoFileDialogFilePicker)
Set oDoc = ActiveDocument
If oDoc.ProtectionType <> wdNoProtection Then
oDoc.Unprotect Password:=""
End If
Set oRng = oDoc.Tables(1).Cell(1, 1).Range
oRng.Text = ""
With Dlg
.Title = "Navigate to folder and Select Picture"
.InitialView = msoFileDialogViewThumbnail
.AllowMultiSelect = False
If .Show <> -1 Then
MsgBox "Cancelled By User", vbInformation, _
"Select Picture"
Exit Sub
End If
strFilePath = .SelectedItems(1)
End With
Set oShape = oDoc.Shapes.AddPicture(FileName:=strFilePath, _
LinkToFile:=False, SaveWithDocument:=True, _
Anchor:=oRng)
oDoc.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=""


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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