+ Reply to Thread
Results 1 to 8 of 8

VBA No Read Only

  1. #1
    Registered User
    Join Date
    09-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    70

    VBA No Read Only

    Hi again all,

    I have some code that should prevent a "Read Only" copy of my workbook being opened. I have inserted it into the Workbook Code, but it has no effect.

    Does anyone have an idea what I may be doing wrong? Wrong code, wrong place to put it - or both?

    Thanks in advance!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA No Read Only Help (Code Included)

    Maybe ...

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,290

    Re: VBA No Read Only Help (Code Included)

    Where in the workbook module.

    Please post a sample workbook.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: VBA No Read Only

    Have you put your code in the ThisWorkbook
    Workbook_Open() event?

  5. #5
    Registered User
    Join Date
    09-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: VBA No Read Only

    thanks for your suggestions guys. I will look at them tomorrow when I'm at work and report back.

  6. #6
    Registered User
    Join Date
    09-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: VBA No Read Only

    Quote Originally Posted by barryleajo View Post
    Have you put your code in the ThisWorkbook
    Workbook_Open() event?
    Hi there,

    Yes I have inserted the code into WorkBook_Open() event.

    Private Sub Workbook_Open()
    If Me.ReadOnly Then
    MsgBox "..."
    Me.Close SaveChanges:=False
    End If
    End Sub
    Have tried this also to no avail.

    Where in the workbook module.

    Please post a sample workbook.

    Regards
    I have attached a essentially blank workbook to show where I have placed the code.

    Any further suggestions?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: VBA No Read Only

    Last bump!

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA No Read Only

    My code works fine if you enable macros when it opens, or macros are enabled automatically via digital signature or opening from a trusted location.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1