Consulting

Results 1 to 3 of 3

Thread: Code to: un-protect w/password, attach document, re-protect with password

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Sep 2019
    Posts
    4
    Location

    Code to: un-protect w/password, attach document, re-protect with password

    Good Morning! 🌞

    I have the code set up for the attach button, but it doesn't function properly when the form is password protected. This is the code I have:

    Private Sub CommandButton2_Click()' Browse & Select File
    With Application.FileDialog(msoFileDialogFilePicker)
            .AllowMultiSelect = False
            .Title = "Select the File that you want to insert"
            If .Show = True Then
                FiletoInsert = .SelectedItems(1)
            Else
                Exit Sub
            End If
        End With
    End Sub
    I need to add code to un-protect the document with a password and re-protect it once the attachment is attached. I've also added to a screenshot to show my protection settings.

    Can anyone assist?

    Thank you!
    Attached Images Attached Images

Posting Permissions

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