1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VBA to save Word as Read-Only

Discussion in 'Business Applications' started by dgetz, Jan 10, 2002.

Thread Status:
Not open for further replies.
Advertisement
  1. dgetz

    dgetz Thread Starter

    Joined:
    Aug 14, 2001
    Messages:
    5
    Anyone know how to save the active document as read-only using VB? ActiveDocument.ReadOnly = True doesn't work because the document is already open.

    Thanks,
    Dan

    Actually, I figured out a way to do it:
    ActiveDocument.WritePassword = "your_password_here"

    This will then cause the document to open up with three options: open (to be able to edit), read-only, and cancel. To be able to open the file, you have to enter the password.

    Of course, make sure to protect your code otherwise, anyone could just look at the code and see the password to edit the document.
     
  2. johnhouk

    johnhouk

    Joined:
    Dec 20, 2001
    Messages:
    17
    I recorded a macro and checked the "Read Only Recommended"
    Then looked @ the code.
    I saw:

    ActiveDocument.ReadOnlyRecommended = True
     
  3. dgetz

    dgetz Thread Starter

    Joined:
    Aug 14, 2001
    Messages:
    5
    Actually, this only recommends that the user opens as read only (I believe). It does not force them to open it as read only. The above code will force them to enter the password if they want to edit it.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/64550