Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default How to hold running Macro?

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


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default How to hold running Macro?

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

"Eric" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default How to hold running Macro?

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

"FSt1" wrote:

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

"Eric" wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pop-up when running a macro tom Excel Discussion (Misc queries) 5 April 2nd 07 08:55 AM
Event Macro running another macro inside K1KKKA Excel Discussion (Misc queries) 1 December 20th 06 08:21 PM
Running one macro from another Megadrone Excel Worksheet Functions 4 December 5th 06 04:54 AM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
Running VBA Macro Jeff Excel Discussion (Misc queries) 1 February 15th 05 01:12 PM


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"