+ Reply to Thread
Results 1 to 9 of 9

VBA Wait - Proceed once File is in Folder (Solved)

  1. #1
    Registered User
    Join Date
    10-23-2019
    Location
    Lincoln, USA
    MS-Off Ver
    2019
    Posts
    5

    VBA Wait - Proceed once File is in Folder (Solved)

    Hello!

    -Using a mixture of vBscript + VBA-

    The vBscript runs a report and generates an excel file & places it into a folder on my computer. I am using VBA to initiate this process, the problem is VBA does not wait for the vBscript to finish generating this excel file & moves on to the next lines of code which causes errors.

    Currently am using Application.Wait Now + Timevalue ("00:00:30") to wait 30 seconds which is working....but next month maybe the reports might need more time.

    How can I make my VBA code smarter? Is it possible for VBA to wait until a file is in a specific folder with a specific name before continuing onto the next lines of code instead of waiting for a set time (30 seconds for example)?
    Last edited by Automatr; 11-15-2019 at 09:57 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: VBA Wait - Proceed once File is in Folder

    You can use a loop to wait until the file exists at specific location.

  3. #3
    Registered User
    Join Date
    10-23-2019
    Location
    Lincoln, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: VBA Wait - Proceed once File is in Folder

    Thank you huuthang_bd for pointing me in a direction. Need to refresh myself on looping and will implement.

    'idea that comes to mind is to "Loop until. Check a specific folder with a specific excel file name to show. Loop this check until the file appears. Once it does, end loop and proceed with code.
    Last edited by Automatr; 11-13-2019 at 11:32 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: VBA Wait - Proceed once File is in Folder

    Quote Originally Posted by Automatr View Post
    'idea that comes to mind is to "Loop until. Check a specific folder with a specific excel file name to show. Loop this check until the file appears. Once it does, end loop and proceed with code.
    That is what I want to say

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Hi !

    Or after initiating the vbScript, all the code should be in this vbScript so VBA has nothing to expect …

  6. #6
    Registered User
    Join Date
    10-23-2019
    Location
    Lincoln, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: VBA Wait - Proceed once File is in Folder

    Hello Marc,

    Unfortunately for these reports -- not an option.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    So the worst path you follow ! So the question is why a vbScript ?! As the easy way is obviously all in VBA or all in vbScript.

    Another way is after initiating the vbScript the main VBA code finishes,
    at the end the vbScript must return a specific value in a specific cell of a sheet of the workbook from where the main VBA ran
    then once this specific value is detected in a specific cell via the Worksheet_Change event the second VBA code is launched …

  8. #8
    Registered User
    Join Date
    10-23-2019
    Location
    Lincoln, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: VBA Wait - Proceed once File is in Folder

    - Edit will respond better later today to explain low on time so typed that out fast -- The event seems like a very good idea that I will look into today.
    Last edited by Automatr; 11-15-2019 at 09:27 AM.

  9. #9
    Registered User
    Join Date
    10-23-2019
    Location
    Lincoln, USA
    MS-Off Ver
    2019
    Posts
    5

    Re: VBA Wait - Proceed once File is in Folder (Solved)

    Good points. I went with your idea of having vBscript editing a cell in excel once finished and having the next lines of vba/vbscript activate. Works like a charm!

    Solved!

    Thanks!!!
    Last edited by Automatr; 11-15-2019 at 10:50 PM.

+ 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. Wait for one IE page to load then wait for a second
    By ckemp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-12-2017, 11:29 AM
  2. Excel 2007 : wait-screen...
    By frits1969 in forum Excel General
    Replies: 2
    Last Post: 04-20-2011, 07:53 AM
  3. I´ll wait for you...
    By TEPUY in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2009, 01:25 PM
  4. Help with Wait X Then Go
    By Ikaabod in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-25-2006, 12:04 PM
  5. Wait for FTP
    By RANDY IN NC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2006, 02:39 PM
  6. [SOLVED] Wait less than a second
    By Claus in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-07-2005, 03:05 PM
  7. [SOLVED] .wait for 1/2 a second
    By Brad in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-09-2005, 11:05 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