On Time
OK I did find a duplicate StartTimer()
I have deleted all code except module1:
Public RunWhen As Double
Public Const cRunIntervalSeconds = 30
Public Const cRUnWhat = "Macro2"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earlisttime = RunWhen, procedu=cRUnWhat, schedule:=True
End Sub
Sub Macro2()
'
'
Application.DisplayAlerts = False
applications.ScreenUpdating = False
Workbooks.OpenText Filename:="C:\Mypath\myfile.txt", _
Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True,
Semicolon:=False, _
Comma:=True, Space:=False, Other:=False, FieldInfo:=Array(Array(1,
1), _
Array(2, 1)), TrailingMinusNumbers:=True
ActiveWorkbook.SaveAs Filename:= _
"C:\Mypath\myfile.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Applications.ScreenUpdating = True
StartTimer
End Sub
and on ThisWorkbook
Private Sub Workbook_Open()
StartTimer
Macro2
End Sub
Macro2 runs on open but the 30 second update is not working
Thanks
"Tom Ogilvy" wrote:
Do you have two procedures named StartTimer? That is the usual cause of this
error. Also, you should not name a module the same as a procedure, although
would be more unlikely to be the case.
--
Regards,
Tom Ogilvy
"Henry" wrote in message
...
Hi Tom
Thanks for the reply
When I open the workbook I get
Compile Error:
Ambiguous name detected: StartTimer
"Tom Ogilvy" wrote:
In the vbe with our workbook as the active project,
Insert=Module
Place it there
To start it, in the project explorer in the vbe, select the ThisWorkbook
entry. In the dropdowns at the top, select workbook on the left and
Open on
the right.
Private Sub Workbook_Open
StartTimer
' or if you want to run you code on opening
'Macro2
End Sub
--
Regards,
Tom Ogilvy
"Henry" wrote in message
...
I am using On Time routine from Chip Pearsons site as Follows:
Public RunWhen As Double
Public Const cRunIntervalSeconds = 30
Public Const cRUnWhat = "Macro2"
Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earlisttime = RunWhen, procedu=cRUnWhat,
schedule:=True
End Sub
Sub Macro2()
My code
StartTimer
End Sub
Where do I sore the code and how do I actually start the procedure/
Thanks!
|