Consulting

Results 1 to 4 of 4

Thread: "Read Only" workbook

  1. #1
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location

    "Read Only" workbook

    If someone opens a read-only copy of a workbook and then tries to run the macros, is it possible to detect that it is a read-only copy and display a warning message. When the user clicks the "OK" button in the warning, the application closes without any other alerts being displayed?


    Thanks

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this.

    Option Explicit
     
     Sub CheckReadOnly()
    Dim MyResponse      As VbMsgBoxResult
    If ActiveWorkbook.ReadOnly = True Then
     MyResponse = MsgBox("This workbook is read only. Do you want to close?", _
         vbYesNo, "Read Only")
         If MyResponse = vbYes Then
             ActiveWorkbook.Close False
         End If
     End If
    End Sub

  3. #3
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location
    Thanks for the quick response Jake.
    It works very well in my workbook.

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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