Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    I have a document that is linked to an Excel workbook. I would like to protect document with read only. But I know that the links will not be able to refresh due to the protection used. So I understand that the document must be unprotected first, then fresh links and then of course reapply read only protection.
    This is what I have so far

    Code:
    Sub AutoOpen()
    With ActiveDocument.Unprotect ("PASSWORD HERE")
     ActiveDocument.UpdateLinks = True
      End If
    End With
    ActiveDocument.Protect wdAllowOnlyReading("PASSWORD HERE")
      End With
     End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    It makes no sense to use With ... End With here.
    A loose "End If" makes no sense either.
    And UpdateLinks doesn't even exist in Word VBA, as far as I know.

    Code:
    Sub AutoOpen()
      Dim fld As Field
      ActiveDocument.Unprotect "PASSWORD HERE"
      For Each fld In ActiveDocument.Fields
    	fld.LinkFormat.Update
      Next fld
      ActiveDocument.Protect wdAllowOnlyReading, "PASSWORD HERE"
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much HansV

Posting Permissions

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