Results 1 to 4 of 4

Thread: Wait Method

  1. #1
    ralph_davies
    Guest

    Wait Method

    The wait method example given in Excel 97 VBA Help doesn't work
    Help !!

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wait Method

    It works fine for me. Can you show us what does not work for you, and tell us what does not work?
    Legare Coleman

  3. #3
    ralph_davies
    Guest

    Re: Wait Method

    I expected the following code to pause execution for about 1 minute but I get zero the same happens if I put eg. newSecond = Second(Now())=20 for 20 seconds.
    I have declared variables as variant.


    newHour = Hour(Now())
    newMinute = Minute(Now()) + 1
    newSecond = Second(Now())
    WaitTime = TimeSerial(newHour, newMinute, newSecond)
    Application.Wait (WaitTime)


    My real problem is that I have a AutoOpen Macro embedded in a Template. I need to re-run the macro from within a file which has been created using the Template. But I also need to re-name the file so it looks like it was created by the Template so that another macro in another file can reference it i.e. it needs to see the file as XXXX1 with no extension where the Template is XXXX.xlt
    I have done this by SaveCopyAs XXXX1 then re-open the file and close the original from which the call to open was made. However since the macro needs to return after the open call in order to close the calling workbook (which of course has macros of the same name as the one which is being opened) The one which is being opened uses the wrong macros and when the original workbook closes data is lost.
    I have tried closing the calling workbook at the beginning of the activated auto open macro but this doesn't appear to work but gives no errors, the book simply stays open.
    I was trying to use the wait to allow the workbook to close before running the auto open code.

    I desperately need help, this problem is driving me around the twist and the Wait not working was the last straw.

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wait Method

    Couldn't you just use FileSaveAs, rather than SaveCopyAs? That way you would not need to close "the original file." If that does not work for you for some reason, then I would use the OnTime method to schedule the execution of the code. I think that using the Wait method is asking for problems.
    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •