Consulting

Results 1 to 3 of 3

Thread: Change Read-Only Status (Excel '97)

  1. #1
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location

    Change Read-Only Status (Excel '97)

    Good morning,

    Is it possible to change the Read Only status of a workbook once it has been opened via VBA?

    Thanks,
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

  2. #2
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    Function IsReadOnly(sWorkBook As String) As Boolean
        Dim sFileFullName As String
        sFileFullName = Workbooks(sWorkBook).FullName
        If  vbReadOnly Then
       IsReadOnly = True
        Else: IsReadOnly = False
        End If
    End Function
    
    Sub test()
    'change activeworkbook.name to any file you want to test
        If IsReadOnly(ActiveWorkbook.Name) Then MsgBox "This workbook is read only"
    End Sub
    Last edited by Aussiebear; 04-11-2023 at 03:52 PM. Reason: Adjusted the code tags

  3. #3
    VBAX Tutor phendrena's Avatar
    Joined
    Oct 2008
    Location
    Huddersfield, UK
    Posts
    285
    Location
    Thanks for the reply.
    Thats not actually what i'm trying to do though.

    I need to change the status of the workbook from or to Read-Only.
    Somewhere in the dark and nasty regions where nobody goes, stands an ancient castle.
    Deep within this dank and uninviting place lives Berk, overworked servant of The Thing Upstairs.
    But thats nothing compared to the horrors that lurk beneath The Trap Door.

Posting Permissions

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