+ Reply to Thread
Results 1 to 7 of 7

Suppress Save request on Read-only file

  1. #1
    Registered User
    Join Date
    08-10-2015
    Location
    Detroit, MI
    MS-Off Ver
    2010
    Posts
    5

    Suppress Save request on Read-only file

    I have a workbook that provides drop down list data to group of worksheets. It needs to be open, but I did not want it visible to the user. So, I open it as:

    Sub Auto_Open()
    Application.ScreenUpdating = False
    Set w = Workbooks
    w.Open Filename:="P:\Troy Personnel\2016\Summary\Personnel Budget Data.xlsm", UpdateLinks:=False, ReadOnly:=True 'this is the data file were going to be opening
    ActiveWindow.Visible = False
    ThisWorkbook.Activate
    Application.ScreenUpdating = True
    End Sub

    This works perfectly. However, when the user closes Excel, it asks them to Save the file. I do not want them to do that, which is why I opened in read-only mode. They still can't save the file, but it is a prompt that I wanted to suppress. I tried this:

    Sub CloseandSave()
    w.Close SaveChanges:=False
    End Sub

    and this:

    Sub Workbook_BeforeClose(Cancel as Boolean)
    w.Close SaveChanges:=False
    End Sub

    Neither work, and I tried to place messages into the close and it looks like it is not even running. Please help this is a major pain!

    Regards,

    David

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Suppress Save request on Read-only file

    Quote Originally Posted by dlangschied View Post
    I have a workbook that provides drop down list data to group of worksheets.
    It may be easier to put the lists on a hidden sheet in the same workbook. The lists would be hidden from the users and you wouldn't have to mess with opening\closing a 2nd workbook.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Suppress Save request on Read-only file

    try putting this at the beginning of the SUB

    Please Login or Register  to view this content.
    and this at the end of the SUB

    Please Login or Register  to view this content.
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  4. #4
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Suppress Save request on Read-only file

    This will pretend that there were no changes made:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-10-2015
    Location
    Detroit, MI
    MS-Off Ver
    2010
    Posts
    5

    Re: Suppress Save request on Read-only file

    There are 20 workbooks that use this sheet. Any changes require changes to all 20. This is sensitive data as well. The owners do not want me to see the data.

  6. #6
    Registered User
    Join Date
    08-10-2015
    Location
    Detroit, MI
    MS-Off Ver
    2010
    Posts
    5

    Re: Suppress Save request on Read-only file

    All the things that I tried did not work. As it turned out it was my perception of WHERE the save was coming from. I was trying to add it to my macro, but no dice. I added the save to the workbook with the lists using beforeclose() and it worked.

    I am sorry to bother all of you.

    I am finding the Excel macro path to be very confusing. I do not, however, have any choice. It is not that Excel is a bad program, but it is very complex.

  7. #7
    Valued Forum Contributor
    Join Date
    09-17-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    454

    Re: Suppress Save request on Read-only file

    A good way to learn vba is to macro record things you normally do manually, and then study the generated code.

+ 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] Save file as read-only
    By mohan.r1980 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-16-2015, 11:44 AM
  2. [SOLVED] Disable save and prevent "Do you want to save" message from prompting for read-only file
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2014, 12:29 AM
  3. [SOLVED] How do I suppress user dialog in File Save As?
    By Tony Lin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2006, 04:00 AM
  4. Replies: 0
    Last Post: 11-29-2005, 10:00 PM
  5. [SOLVED] Trying to save a .XLA file that's Read Only
    By silkworm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2005, 09:25 PM
  6. request macro to save file to multiple, separate locations
    By Joseph Spain in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2005, 10:46 AM
  7. How do I save a read only file or folder?
    By Dick in forum Excel General
    Replies: 3
    Last Post: 03-04-2005, 12:06 AM

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