How to hold running Macro?

G

Guest

Does anyone have any suggestions on how to hold Macro running until specific
file being updated?

When I run a Macro, in the middle of the process, I would like to hold Macro
running until the periods between the last updated time for specific file and
the current time is less than a hour.
For example, a Macro is running under the Eric.xls

Sub temp()
Application.DisplayAlerts = False

Workbooks.Open Filename:="C:\A.xls", UpdateLinks:=3
Workbooks("A.xls").Close savechanges:=True

Before processing the next step, I would like to check the last updated time
for specific files - Mary.xls with the current time. If the difference
between the last updated time for Mary.xls and the current time is less than
1 hour, then process the next coding, else wait until the difference periods
is less than 1 hour.

Workbooks.Open Filename:="C:\B.xls", UpdateLinks:=3
Workbooks("B.xls").Close savechanges:=True

End Sub

Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric
 
G

Guest

hi,
one way is to use the application.wait method. see vb help.
but i would incorporate the checking into the macro. after udating A.xls, i
would get it's update time and assign it to a variable. then open mary.xls
and assign it's update time to a variable. then subract the two variables. if
less than one hour, message box "less than one hour. process terminated". ok
= exit sub. you could even display the two variable in the message box so you
would know how long the wait would be.
my thoughts
regards
FSt1
 
G

Guest

Thank you for your reply
Could you please show it in VBA coding?
Thank you for any suggestions
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top