Automation or Win32 for memory efficiency

A

Aidy

I am using a VBA that is not Excel. But I was using a wrapper around
Excel's 'Wait' method to add delays.

Here is the code: (modified from Excel's help)

Public Sub DelayFor(iwaitTime As Integer)
Dim oExcel As Excel.Application
Dim newHour, newMinute, newSecond, waitTime

Set oExcel = New Excel.Application

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + iwaitTime
waitTime = TimeSerial(newHour, newMinute, newSecond)
oExcel.wait waitTime

Set oExcel = Nothing
End Sub

However would it be more memory efficient to use the sleep win32
function?

Aidy
 
P

Perry

However would it be more memory efficient to use the sleep win32
function?

Yup, one wud say so.
If you only need oExcel to access the .Wait() method, then
it will certainly be more efficient to perform a delay in yr code using
Sleep()

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Krgrds,
Perry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top