+ Reply to Thread
Results 1 to 9 of 9

VBA not work when file is Read Only

  1. #1
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    VBA not work when file is Read Only

    Hello everyone,

    I have this code and I want to know if there is a way to add something that when the file is read only none of the macros works.

    Thanks for oyur replis.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: VBA not work when file is Read Only

    How about saving a copy of the file without any macros?
    OR
    Add this line at the beginning of every sub
    Please Login or Register  to view this content.
    Edit
    Oh dear!
    - in school, I was always taught to read the question properly (but that was a very long time ago)
    - this suggestion works for Excel but not for Word
    Thank you @AliGW for the catch
    Last edited by kev_; 02-18-2018 at 04:57 AM.
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,369

    Re: VBA not work when file is Read Only

    I think this is a Word macro query, Kev.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA not work when file is Read Only

    Word documents have two properties you can test:
    .ReadOnly
    .ReadOnlyRecommended
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: VBA not work when file is Read Only

    Quote Originally Posted by macropod View Post
    Word documents have two properties you can test:
    .ReadOnly
    .ReadOnlyRecommended
    But how can I add this to my existing macro?

    Thank you

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA not work when file is Read Only

    Did you at least look at those properties in Word's VBA help file?

  7. #7
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: VBA not work when file is Read Only

    Of course I did.
    But I'm a newbie in VBA, and learning by reading and asking.

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: VBA not work when file is Read Only

    The VBA help for .ReadOnly should have been hint enough. The code Kev posted in post #2 gives an additional pointer. After:
    With ActiveDocument
    Insert:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    08-20-2013
    Location
    LX
    MS-Off Ver
    Office 2019
    Posts
    164

    Re: VBA not work when file is Read Only

    Quote Originally Posted by macropod View Post
    The VBA help for .ReadOnly should have been hint enough. The code Kev posted in post #2 gives an additional pointer. After:
    With ActiveDocument
    Insert:
    Please Login or Register  to view this content.
    Thanks for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How do I save a file as non-read only from a read only
    By tomneedshelp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-28-2016, 11:17 AM
  2. [SOLVED] Checking to see if a file has been opened in Read/Write or Read Only
    By brokenbiscuits in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-13-2014, 09:16 AM
  3. Read-only file on server. How many people can read at once?
    By Xx7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 12:10 AM
  4. Replies: 5
    Last Post: 06-26-2012, 02:00 PM
  5. Using ADO to read closed file does not read formulas
    By treyr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-09-2010, 12:26 PM
  6. [SOLVED] I have a read only xl file, I need it to be read and write
    By drama queen in forum Excel General
    Replies: 3
    Last Post: 06-30-2006, 07:30 PM
  7. How can a file be converted from Read-Only to Read/Write
    By Jim in Apopka in forum Excel General
    Replies: 2
    Last Post: 11-19-2005, 01:00 PM

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