+ Reply to Thread
Results 1 to 5 of 5

VBA stop macro if the file we refer to is not opened

  1. #1
    Registered User
    Join Date
    06-21-2013
    Location
    Wro
    MS-Off Ver
    Excel 2007
    Posts
    18

    VBA stop macro if the file we refer to is not opened

    Hi Guys.

    Just a quick question:

    Please Login or Register  to view this content.
    How to modify it into: continue marco if workbook.xls is open, or stop macro, if workbook.xls is not open.

    Sorry for the noobity level of the question

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA stop macro if the file we refer to is not opened

    Try:
    HTML Code: 
    PS. Pana Łukasza oczywiście zapraszamy na polską wersję forum czyli z .pl na końcu. Ekipa z Wrocka jest dość licznie reprezentowana :-)
    Best Regards,

    Kaper

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: VBA stop macro if the file we refer to is not opened

    or
    Please Login or Register  to view this content.

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA stop macro if the file we refer to is not opened

    Of course you don't have to remember "magic 64" - there is a constant vbInformation
    Or I suppose, such situation shall trigger higher level of alert so vbCritical (16) will be more appropriate.
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: VBA stop macro if the file we refer to is not opened

    And more basic question - May be instead of stopping macro it would be more appropriate to automaticaly open it (especially easy if we know the path).

    Using my example (but could be also applied to one presented by nilem:

    Please Login or Register  to view this content.

+ 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: 3
    Last Post: 02-25-2013, 03:18 PM
  2. macro prompts immediately to open a file once the Excel file with the macro is opened
    By jhmayor03 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2012, 10:00 AM
  3. stop excel file opened as read only if already opened by another u
    By bobm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-09-2011, 08:45 AM
  4. [SOLVED] How to stop Excel remembering/loading macro from previously opened Workbook
    By Norman Yuan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-17-2006, 11:15 AM
  5. Replies: 4
    Last Post: 06-17-2006, 11:15 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