Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


timed macros running twice

timed macros running twice

timed macros running twice

Hello all,
I have been searching and am unable to find an answer to my problem.
I hope someone can help.
I have macros that run at certain times everyday. They run through Excel but perform a function in attachmate.
They work just fine... My problem is this:
If the Excel workbook the macros run from is open on another computer the macros will run twice. if open on 3 computers they run 3 times.
How can i prevent them from runing in all instances of Excel that are open?
One primary employee has the excel workbook open all day. but another might open it from time to time. if both are open at run time... both run the macro.
Any help will be greatly appreciated!


RE: timed macros running twice

I would keep a log table that stores when the macro has been run. Then check this table prior to running.

Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016

RE: timed macros running twice

You might also consider redesigning the Excel workbook system. Your users' workbooks would be a frontend to a backend workbook that would contain the data that your access macros tap and that would run your Attachmate screen scrape.

I'd also put a timer on the users' workbooks to save & close after x minutes of inactivity.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: timed macros running twice

dhookom & SkipVought,
Thank you for the quick reply and the ideas. However: your ideas led me in a completely new direction I hadn't considered...
It is one specific PC that the opener uses that will (or should) run my timed Macros. Any other Pc with the specific workbook open are secondary.
With that in mind I concluded I could ID that specific PC then run a check to see if that specific PC was running the workbook... If so, the Timed Macros would run.
I used...
Dim PCName As String
PCName = Environ$("ComputerName")
Run MyOtherCode

'I ran the Macro with a message box to learn the PC's ID then put that data in Sheets("Data").Range("M21") and continued...

If PCName = Sheets("Data").Range("M21").Value Then

Application.OnTime TimeValue("06:30:00"), "Run_Ardaa"
Application.OnTime TimeValue("08:00:00"), "BreakTymes"
Application.OnTime TimeValue("10:00:00"), "LunchTyme"
Application.OnTime TimeValue("12:30:00"), "BreakTymes"
End If

This worked beautifully for my configuration.

Problem solved.

Thank you again.


RE: timed macros running twice



glassesJust traded in my OLD subtlety...
for a NUance!tongue

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close