View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Thomas Thomas is offline
external usenet poster
 
Posts: 107
Default Run an Excel code every 15 minutes of the clock

Peter,

The "Now" got flagged for "Compile Error: Invalid Outside Procedure".

But how do I incorporate your code into mine as follows:

Option Explicit
Private Declare Function GetProcessVersion Lib "kernel32" ( _
ByVal ProcessID As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function CloseHandle Lib "Kernel32.dll" (ByVal Handle As
Long) As Long
Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal
dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As
Long) As Long
Private Declare Function EnumProcesses Lib "PSAPI.DLL" (ByRef lpidProcess As
Long, ByVal cb As Long, ByRef cbNeeded As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "PSAPI.DLL" (ByVal
hProcess As Long, ByVal hModule As Long, ByVal ModuleName As String, ByVal
nSize As Long) As Long
Private Declare Function EnumProcessModules Lib "PSAPI.DLL" (ByVal hProcess
As Long, ByRef lphModule As Long, ByVal cb As Long, ByRef cbNeeded As Long)
As Long
Public RunWhen As Double
Public Const cRunIntervalSeconds = 900
Public Const cRunWhat = "Make_SGX_Txt" ' the name of the procedure to run
Dim FirstTime As Boolean
Sub StartTimer()

If FirstTime Then
RunWhen = Date + TimeSerial(8, 45, 0)
Else
If Time TimeSerial(8, 45, 0) And Time <= TimeSerial(12, 30, 0) Or Time
TimeSerial(13, 59, 0) And Time < TimeSerial(17, 10, 0) Then

RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
End If
End If

Application.OnTime EarliestTime:=RunWhen, _
Procedu=cRunWhat, Schedule:=True

End Sub

Sub Make_SGX_Txt()

Dim ProcID As Long
Dim Version As Long
Dim LastErr As Long
Dim ThisProcID As Long
ProcID = 1092

{ what I want to do }



Thomas