+ Reply to Thread
Results 1 to 4 of 4

if data file is opened as read only, then the macro gives an "error" message

  1. #1
    Registered User
    Join Date
    02-16-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    if data file is opened as read only, then the macro gives an "error" message

    Hello!

    I am new to VBA and have been learning from the web for the past few days, so far I have been doing with google as my teacher, but today I got a little stuck so I would like some help. I apologize if I am missing details or if my code is too novice.

    I have a template where different users will be inputting data, then that data is being transferred to another "data" file. The problem I have is that at some point of the day the "data" files will be opened to be serviced (move/delete data.) I want the user to have a smooth experience with the template and not experience any runtime/VBA errors of any kind. My problem is the following: after the data is entered and the user clicks the "submit" button, the data is exported to the data files and they get a message saying "your request has been submitted. Thank you." Til then so far so good, but in case the data file is open by someone then excel will open it as read only, I want the code to error somehow and the user gets a message that says "Our data files are currently being updated. Please try again later."

    I first tried "On error resume next," but since I have Displayalerts as False, Excel is not really erroring but instead going with the defaults. When the data file is opened as "read only" what excel does is save new copy of the file one folder up to the one where the file is originally at (if that even made sense) and it never errors, so no luck with this option.

    Please Login or Register  to view this content.
    this code I got it from someone else, but the goal is somewhat different from what I need. If this code errors, then the code prompts the user to "save as." Thought I could use this as a base and modify to what I need, but so far no luck


    Please Login or Register  to view this content.


    any help is greatly appreciated thanks so much!!
    Last edited by Leith Ross; 04-02-2014 at 10:17 PM. Reason: Added Code Tags

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: if data file is opened as read only, then the macro gives an "error" message

    See this thread http://www.excelforum.com/excel-prog...book-open.html

    Alter the Msgbox to display the messages you want. (You don't need to return the other users name in the Msgbox if you don't want to - but it can be handy! Particularly if you want to PM them to close the file they have open! )
    Last edited by Leith Ross; 04-02-2014 at 10:18 PM. Reason: Removed Quote - Not Necessary
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  3. #3
    Registered User
    Join Date
    02-16-2014
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: if data file is opened as read only, then the macro gives an "error" message

    perfect!! I will give it try today, hope it works. Thank you much for the help

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: if data file is opened as read only, then the macro gives an "error" message

    If your thread is solved, please use 'Thread Tools' to mark it SOLVED as a courtesy to other forum users.

    If my posts helped solve your thread, please consider taking a few seconds to click '* Add Reputation' on the post that helped. Thank you.

+ 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. Replies: 2
    Last Post: 10-15-2005, 10:05 AM
  2. Replies: 0
    Last Post: 10-12-2005, 12:05 PM
  3. Error message "Unable to read file"
    By Jecakias in forum Excel General
    Replies: 0
    Last Post: 03-11-2005, 02:18 PM
  4. Error message "Unable to read file"
    By Jecakias in forum Excel General
    Replies: 0
    Last Post: 03-11-2005, 01:53 PM
  5. Replies: 1
    Last Post: 02-07-2005, 05:06 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