Satin,
This
Now + TimeSerial(0, 0, 5)
is what's causing your problems. Try something like this:
Dim xlapp As New Excel.Application
Dim xlwb As Excel.Workbook
xlwb = xlapp.Workbooks.Open("D:\sample.xls")
xlwb.Application.OnTime(Now.AddSeconds(5), "SubName")
where SubName is a public Sub inside a module in the sample.xls file.
--
Hope that helps.
Vergel Adriano
"Satin" wrote:
I am writing a VB.NET plugin for Excel. I want to call the
ApplicationObject.Ontime function to call another function after a specified
time.
AppObj.OnTime Now + TimeSerial(0, 0, 5), "MyCustom SubName"
I tried putting the calling and called function in the same class but it
throws an error. "Exception from HRESULT: 0x800A03EC."
I also tried putting the called function in a Global Module but no success..
still the same exception.
This thing works in a Macro( wherein i specify ThisworkBooK.<CALLED FUNCTION
Name)
Does the Ontime Function work in an application or just that it works in a
Macro?
If it does, what is the right way to call it?
thanks for your suggestions.
-Satin