+ Reply to Thread
Results 1 to 3 of 3

How to make a macro run only if not READ ONLY

  1. #1
    Registered User
    Join Date
    05-02-2011
    Location
    Kansas City, MO
    MS-Off Ver
    Excel 2007
    Posts
    1

    How to make a macro run only if not READ ONLY

    I have a macro already that refreshes data sources in a workbook via an ODBC connection to my SQL server. Only a few users have access to that ODBC connection, but many other users open the workbook in read only mode.

    Is there a way that i can have the macro set to run only if it is NOT READ ONLY?

    Thanks,
    Jeremiah

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to make a macro run only if not READ ONLY

    Hi,

    You could use the GetAttr syntax to return the read only file attribute and direct your macro accordingly.
    i.e.
    Please Login or Register  to view this content.
    will return 1 if the file is read only.

    The full attribute list is:

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,429

    Re: How to make a macro run only if not READ ONLY

    You can check the Readonly property of the workbook and exit the macro if true.
    Cheers
    Andy
    www.andypope.info

+ 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