Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2004

Tip: Looking for answers? Try searching our database.

Auto run a macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Clarke - 18 Nov 2004 21:47 GMT
I need this to run automatically every specified amount of time, but this
code isn't working...

Public Sub AutoDelay()
   
   Application.OnTime When:=Now + TimeValue("00:05:00"),
       Name:="AutoSave"

End Sub
Public Sub AutoSave()
   ActiveDocument.Save
End Sub

If you have a better suggestion, please post it. Thanks!
Peter - 18 Nov 2004 22:08 GMT
Some things to keep in mind when using the OnTime method:
- The macro that is going to be called at each interval needs to be public.
- You need to specify the name of the module with the macro name.
- Inside that macro, you need to reset the timer.

Public Sub AutoDelay()
   Application.OnTime When:=Now + TimeValue("00:05:00"), Name:="Module1.AutoSave"
End Sub
Public Sub AutoSave()
   ActiveDocument.Save
   Application.OnTime When:=Now + TimeValue("00:05:00"), Name:="Module1.AutoSave"
End Sub

hth,

-Peter

> I need this to run automatically every specified amount of time, but this
> code isn't working...
[quoted text clipped - 10 lines]
>
> If you have a better suggestion, please post it. Thanks!

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.