+ Reply to Thread
Results 1 to 4 of 4

Macro that waits, then resumes after window is closed

  1. #1

    Macro that waits, then resumes after window is closed

    Does anyone know how to do the following:

    I have a macro that does some things
    including open up a workbook, then I need the macro to wait until this
    workbook is closed while I edit some values, then proceed with the rest
    of the macro.


    Any ideas?

    Thank you all in advance.


  2. #2
    Bob Phillips
    Guest

    Re: Macro that waits, then resumes after window is closed

    You will need 2 macros, one that opens the workbook and stops, and then trap
    the BeforeClose event of that workbook.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    <[email protected]> wrote in message
    news:[email protected]...
    > Does anyone know how to do the following:
    >
    > I have a macro that does some things
    > including open up a workbook, then I need the macro to wait until this
    > workbook is closed while I edit some values, then proceed with the rest
    > of the macro.
    >
    >
    > Any ideas?
    >
    > Thank you all in advance.
    >




  3. #3
    Dave D-C
    Guest

    Re: Macro that waits, then resumes after window is closed

    How do you 'stop' in VBA?
    If you Exit Sub, then how do you get going again?
    If you find better than this, please let me know:

    Sub Main() ' (XL97/WIN98)
    Dim WBName$, i%
    Workbooks.Add
    WBName = ActiveWorkbook.Name
    MsgBox "Just opened " & Workbooks(WBName).Name
    Do While XLWinStat(WBName) ' this is the 'wait' loop
    ' the for..next is to not hog the system
    For i = 1 To 1000: DoEvents: Next i
    Loop
    MsgBox WBName & " is closed. Am proceeding ..."
    End Sub

    Function XLWinStat%(WBName$)
    On Error GoTo XLWSerr
    If Workbooks(WBName).Name = WBName Then
    XLWinStat = 1: Exit Function
    End If
    Stop ' never gets here
    XLWSerr: ' gets here when WBName is closed
    End Function

    Bob wrote:
    >You will need 2 macros, one that opens the workbook and stops, and then trap
    >the BeforeClose event of that workbook.


    michael wrote
    >> Does anyone know how to do the following:
    >> I have a macro that does some things
    >> including open up a workbook, then I need the macro to wait until this
    >> workbook is closed while I edit some values, then proceed with the rest
    >> of the macro.



  4. #4
    Ron Rosenfeld
    Guest

    Re: Macro that waits, then resumes after window is closed

    ignore please
    --ron

+ 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