Consulting

Results 1 to 2 of 2

Thread: Solved: unprotect sections of word document with excel

  1. #1
    VBAX Regular
    Joined
    Jun 2009
    Posts
    79
    Location

    Solved: unprotect sections of word document with excel

    Hi,

    I have a program that pushes values from Excel to a Word template. Part of the word template has a protected section (section2) and I need to somehow disable the protection with the excel vba and once everything has been completed to put the password back on the section.

    I've been trying to search for this, but I can only find how to protect the whole document.

  2. #2
    VBAX Tutor Benzadeus's Avatar
    Joined
    Dec 2008
    Location
    Belo Horizonte, Brazil
    Posts
    271
    Location
    [VBA]Sub Proccess_Word_Document()

    Const strPassword As String = "password"

    Dim wdApp As Word.Application
    Dim wdDoc As Word.Document

    Set wdApp = GetObject(, "Word.Application")
    Set wdDoc = wdApp.Documents(1)

    wdDoc.Unprotect strPassword
    'Do actions
    wdDoc.Protect Password:=strPassword, Type:=wdAllowOnlyReading

    Set wdDoc = Nothing
    Set wdApp = Nothing

    End Sub[/VBA]

Posting Permissions

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