+ Reply to Thread
Results 1 to 3 of 3

If msgBox "File is locked for editing appears" then click cancel and end macro

  1. #1
    Registered User
    Join Date
    11-18-2015
    Location
    Missouri, U.S.
    MS-Off Ver
    Microsoft XP; Window 10
    Posts
    1

    If msgBox "File is locked for editing appears" then click cancel and end macro

    Hi,

    I am creating a macro that copies info from workbook A, into workbook B, then saves and closes workbook B. However, when Workbook B is in use by another user, the macro stops and a message appears saying "File in use by another user (blah). Do you want to read only or save another copy?"

    When this happens, I want the macro to click cancel, close workbook B, display a msgbox saying "File in use already, and end the macro. Try again later".

    I would like code something like:



    If errorbox appears then
    click cancel
    ActiveWorkbook.DisplayAlerts = false
    Activeworkbook.close
    Exit Sub
    End If




    Help?

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,767

    Re: If msgBox "File is locked for editing appears" then click cancel and end macro

    Solution already pre made available in Microsoft website

    Please Login or Register  to view this content.
    Source:

    https://support.microsoft.com/en-us/kb/291295


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: If msgBox "File is locked for editing appears" then click cancel and end macro

    I think you may just test if workbook b is read only.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

+ 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. Getting "This file is locked for editing"
    By aka.mo in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 03-01-2014, 12:29 AM
  2. [SOLVED] Getting file name "False.xlsm" when I click 'Cancel' on the 'Save as' window
    By LewisM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2014, 01:04 PM
  3. [SOLVED] How to enable user to click "cancel" if file name exists when saving as...
    By TBO in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2014, 02:22 PM
  4. Replies: 0
    Last Post: 03-05-2013, 07:22 PM
  5. "PERSONAL.XLSB is locked for editing" notice when opening second instance of excel
    By csch123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2012, 02:06 AM
  6. Replies: 1
    Last Post: 10-29-2009, 01:37 PM
  7. Replies: 1
    Last Post: 04-26-2006, 01:00 PM
  8. [SOLVED] Stop code from running when I click "Cancel"
    By Dean in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2006, 08:40 PM

Tags for this Thread

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