Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Every 10 second autosave/excel macro

2,506 views
Skip to first unread message

Christopher

unread,
Jul 9, 2001, 3:20:39 PM7/9/01
to
I need to get an excel spreadsheet to save as a tab
delimited text file automatically without supervision
every ten seconds (autosave only works every 1 min).

1) Is there a way to do this?
2) Is there a way to have a cell call a macro every time
that it is executed? I wrote a macro that tries to save
current worksheet, and can make a cell that changes value
every 10 seconds (using second()), but I don't know how to
get the macro to be called by the cell.


Ron de Bruin

unread,
Jul 9, 2001, 3:35:12 PM7/9/01
to
Try this

put starttimer in the workbook open and put stoptimer in the workbook close

Regards Ron

Public RunWhen As Double
Public Const cRunIntervalSeconds = 10
Public Const cRunWhat = "The_Sub"


Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub


Sub The_Sub()
MsgBox ""
'
' your code here
'
StartTimer
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub

"Christopher" <c...@d.com> schreef in bericht
news:25c301c108ac$3d1889e0$a5e62ecf@tkmsftngxa07...

Christopher

unread,
Jul 9, 2001, 4:08:54 PM7/9/01
to
Hi Ron,

Thanks for the help. Can I ask you to give a little
more information. I have only a very rudimentary
familiarity with visual basic and excel macros (but I am
fairly computer/programming savvy generally). I don't
know what starttimer or workbook open or close are or how
to go about doing this. Also, will this close and reopen
the workbook every time (as opposed to just saving it?).

Thanks,

Christopher

>.
>

Ron de Bruin

unread,
Jul 9, 2001, 4:23:15 PM7/9/01
to
When the start the workbook the starttimer sub is run, every 10 seconds the
The_Sub macro is running( put your save code in there)

When the workbook is closed the stoptimer sub is run to stop running the sub
every 10 seconds.

I hope you understand it, if not mail back.

Regards Ron

---------------------------------------------------------------------
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub

Private Sub Workbook_Open()
StartTimer
End Sub

put this two subs under thisworkbook in the VBA editor(alt- f11)

---------------------------------------------------------------

And copy and paste these subs in a normal module

Public RunWhen As Double
Public Const cRunIntervalSeconds = 10
Public Const cRunWhat = "The_Sub"


Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedure:=cRunWhat, _
schedule:=True
End Sub

Sub The_Sub()
MsgBox ""
'
' your code here
'
StartTimer
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedure:=cRunWhat, schedule:=False
End Sub

---------------------------------------------------------


"Christopher" <c...@d.com> schreef in bericht

news:457901c108b2$fab01850$9ae62ecf@tkmsftngxa02...

Ron de Bruin

unread,
Jul 9, 2001, 4:27:50 PM7/9/01
to
Thisworkbook.save

Will save the workbook for you, put this in the sub that run every 10
seconds

Ron


"Ron de Bruin" <ronde...@kabelfoon.nl> schreef in bericht
news:OZiJVTLCBHA.1288@tkmsftngp02...

rp30...@gmail.com

unread,
Nov 25, 2014, 9:33:03 AM11/25/14
to
Hi Ron,

Even I am looking for the solution for the above mentioned problem.
I tried your VBA code. But I am not able to get the results. Definitely I making a mistake somewhere as I am very new to VBA.
Is it possible for you to send me excel which is ready to use and already loaded with the VBA code which automatically refreshes the excel after every 2 seconds.
It will be great help pls. As its required urgently. Your help will be serioulsy appreciated.

With Regards,
RAJ.
0 new messages