Shift to Read Only Macro

Hello - This is an Excel Read Only macro I have.  Is there something similar to word?  I'd like to shift between Read Only & Read/Write more easily than opening & closing the document.

Sub ReOpenReadOnly()

  Dim Fullname As String

 

  With ActiveWorkbook

    'New file?

    If .Path = "" Then Exit Sub

    'Already readonly?

    'Save the path\file name of the current file

    Fullname = .Fullname

    'Close it, ignore changes

    .Close False

  End With

  'ReOpen readonly

  Workbooks.Open Fullname, ReadOnly:=True

End Sub

Change ActiveWorkbook to ActiveDocument and Workbooks to Documents.

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thanks!  Works great!  Is there script to do the opposite?  Shut Read-Only & Open as Read/Write?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Use:

Dim fullname As String
With ActiveDocument
    If .ReadOnly = True Then
    fullname = .fullname
    .Close
End With
Documents.Open fullname, ReadOnly:=False

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

The following seems to work OK as a toggle macro...

Sub ReadOnlyToggle()
' http://answers.microsoft.com/en-us/office/forum/office_2010-word/shift-to-read-only-macro/33c5309f-5d3f-490d-acc0-d64ac149f6ae
' Thanks to Doug Robbins 9/2014
  Dim fullname As String
 
  If ActiveDocument.ReadOnly = True Then
     With ActiveDocument
        fullname = .fullname
        .Close
    End With
    Documents.Open fullname, ReadOnly:=False
    Exit Sub
  End If

  With ActiveDocument
    'New file?
    If .Path = "" Then Exit Sub
    'Already readonly?
    'Save the path\file name of the current file
    fullname = .fullname
    'Close it, ignore changes
    .Close False
  End With
  'ReOpen readonly
  Documents.Open fullname, ReadOnly:=True


End Sub

Volunteering to "pay forward" the help I've received in the Microsoft user community.

Charles Kenyon
Sun Prairie, Wisconsin
wordfaq[at]addbalance[dot]com

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 14, 2025 Views 219 Applies to: