+ Reply to Thread
Results 1 to 8 of 8

Changing the Read-only Property by code

  1. #1
    Forum Contributor
    Join Date
    04-18-2009
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2016
    Posts
    269

    Changing the Read-only Property by code

    Hi,

    Is there a way to change the 'Read-only' property of any Excel file dynamically by writing some code?

    I tried 'ThisWorkbook.ReadOnly = False', but it doesn't work.

    --Karan--

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

    Re: Changing the Read-only Property by code

    No, it's a read-only property.

    What exactly are you trying to do?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    04-18-2009
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2016
    Posts
    269

    Re: Changing the Read-only Property by code

    Thanks for the prompt reply Andy.

    Actually, I am trying to secure one of the add-ins that I have made (to protect against direct distribution). So, in the Auto_Open module of the add-in, I have written some code to check the user name of the user:

    Please Login or Register  to view this content.
    I have made an installer with the .xla file. Now, when the user installs, the add-in is sometimes installed as 'Read only'. So, in the third line in the above code, it gives me an error, i.e. the workbook cannot be saved. So, the entire idea of protecting the add-in from unauthorized distribution doesn't work (as the Menubar would be created only if the Username of the current computer matches with the Username of the computer on which the add-in was opened for the first time).

    I hope I am clear in expressing my requirements.

    Thanks for all the help!!!

    Regards,
    Karan

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

    Re: Changing the Read-only Property by code

    Maybe you should add error checking and not allow the addin to be used if you can not update it.

  5. #5
    Forum Contributor
    Join Date
    04-18-2009
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2016
    Posts
    269

    Re: Changing the Read-only Property by code

    Clients using this add-in are not so tech savvy. I think they might not be able to update the add-in properties.

    Do you know if there is any other alternative to change the read-only status or to protect direct distribution of the add-in?

    Thank you for your time.

    --Karan--

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

    Re: Changing the Read-only Property by code

    This appears to work for a normal xls file.

    Please Login or Register  to view this content.
    I used the Open Read only option on the Open dialog when testing.

    One thing that may be a problem is if the addin is in a shared folder where the user only has read-only access. Then you would not have the privilge to overwrite your addin.

  7. #7
    Forum Contributor
    Join Date
    04-18-2009
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2016
    Posts
    269

    Re: Changing the Read-only Property by code

    Hi Andy,
    Thanks for the help.

    In the .xla, I am getting the following error, on the line 'ThisWorkbook.SaveCopyAs ThisWorkbook.FullName' : "Cannot access read-only document" 'File Name.xla'

    Do you know a way to get over this?

    I tried working with this code on a .xls file too, but it gives the same error. If you have a sample file, can you please attach it?

    Regards,
    Karan
    Last edited by karan; 05-22-2009 at 09:18 AM. Reason: more information

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

    Re: Changing the Read-only Property by code

    As I said.
    "One thing that may be a problem is if the addin is in a shared folder where the user only has read-only access. Then you would not have the privilge to overwrite your addin."

    This is not an excel issue so much as an OS one. The actual fill is marked as read-only rather than just being opened as read-only.

+ 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