Disable Excel Macros in read only workbook?
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Disable Excel Macros in read only workbook?

  1. #1
    Guest

    Default

     
    Is it possible to force excel to disable all macro's or all form buttons when a workbook is opened as read only?

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Bogota, Colombia
    Posts
    11,959
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I don't think so, but, you could add a condition at the beginning of your code to test if the workbook is read only, and if it is, Exit Sub.

    If ActiveWorkbook.ReadOnly then Exit Sub
    Regards,

    Juan Pablo González
    http://www.juanpg.com

  3. #3
    New Member
    Join Date
    Feb 2002
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Unless someone has a better suggestions - I would just insert the following code at the start of your routines.

    If ActiveWorkbook.ReadOnly Then
    exit sub
    End If

    If you have a lot of routines then I would suggest you create an xla file with all thes processes etc which is called by the workbook - in that case you would load the xla only if the file was not a read-only file
    as in the following example.

    If ActiveWorkbook.ReadOnly Then
    exit sub
    else
    Workbooks.Open FileName:="my_xla_file.xla"
    End If

    Hope this helps.

    John

  4. #4
    Guest

    Default

      
    That worked great! Thanks.
    Erik

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