Opened ReadOnly Flag in VBA?
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Opened ReadOnly Flag in VBA?

  1. #1
    New Member
    Join Date
    Feb 2002
    Location
    Dallas, Texas
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I've got an Excel workbook that I've saved with the password required to modify file sharing option (under Save As / Options).

    For some reason I haven't been able to figure out yet, simply opening the workbook read only & immediately closing it without making any changes sets the dirty bit & the user is prompted to save changes on close.

    Until I can figure out what's setting the dirty bit, I'd like to test the Saved property in a Workbook_Close routine and allow the user to close without saving, but only if the workbook was opened read only.

    Is this possible? If so, what property can I test to see if the workbook was opened read-only?

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,936
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Quite easy this:-

    Code:
    Sub Test()
    If ThisWorkbook.ReadOnly = True Then
        MsgBox "This is Readonly"
    Else
        MsgBox "This is a read/write workbook"
    End If
    End Sub
    HTH,

    D

  3. #3
    New Member
    Join Date
    Feb 2002
    Location
    Dallas, Texas
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks d, works brilliantly.

    I knew it had to be easy.

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com