Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Inserting pictures into a form (2002/XP)

    Hi,

    I am putting together a form in Word 2002/XP. I have inserted several text fields which are working fine, and I have protected the form. However, I also want to include a field which enables the user to insert a picture. I can't see an easy way of doing it - does anybody have any ideas or workarounds?

    Thanks, Laurie

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Inserting pictures into a form (2002/XP)

    You could insert a MACROBUTTON field in the document. You will have to unprotect the document, insert the picture, then protect the document again in the macro executed by the MACROBUTTON. Example code:

    Sub InsertAPicture()
    Dim strFile As String
    With Application.FileDialog(msoFileDialogFilePicker)
    .Filters.Add "Graphics files", "*.gif;*.jpg;*.png"
    .Title = "Select a picture"
    If .Show Then
    strFile = .SelectedItems(1)
    ActiveDocument.Unprotect
    ActiveDocument.InlineShapes.AddPicture strFile, , , Selection.Range
    ActiveDocument.Protect wdAllowOnlyFormFields, True
    End If
    End With
    End Sub

  3. #3
    Star Lounger
    Join Date
    Jan 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting pictures into a form (2002/XP)

    Hi Hans,

    Thanks for this, but it is not quite what I need the form to do. I can see that this would be an effective way of selecting an image, but if the user unprotects the form they can insert a picture by going Insert, Picture from the menu bar.

    Is there a way that the form can remain protected, but the user is able to insert a picture into a part of the form. Currently I cannot find a way of specifying a field to be used for a picture. For example, if you try inserting a picture into a text field, the Insert, Picture command is greyed out.

    Thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Inserting pictures into a form (2002/XP)

    There is no "picture" form field.

    You can leave part of a document unprotected (the Tools | Protect Document... dialog lets you specify which sections of a document are protected). The user can insert a picture in unprotected sections.

    There is no way to insert a picture in a protected section of the document. You will have to unprotect the document, insert a picture, then reprotect the document. The macro I posted above shows how this can be done in code, without the user even knowing that the document was unprotected temporarily.

  5. #5
    Star Lounger
    Join Date
    Jan 2002
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Inserting pictures into a form (2002/XP)

    Wow I hadn't realised your code unprotected the document as well. That is great. And now I know you cannot insert pictures into a protected form, I can choose which of your 2 methods to use.

    That is brilliant. Thanks for your help.

    Laurie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •