Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 866
  • Last Modified:

Cant create Object for SetTimeout method

I am currently working in Outlook 2003 code behind the forms. This is vbscript based. When I try to run the following snippet of code behind the form I get the following:

 Microsoft VBScript runtime error: Object required: 'windows'



Test
 
    Dim dtmStartTime

    Sub Test()
       
       
        dtmStartTime = Now
        idTimer = windows.setTimeout("PausedSection", 5000, "VBScript")
    End Sub

    Sub PausedSection()
        Msgbox dtmStartTime & vbCrLf & Now
        window.clearTimeout(idTimer)
    End Sub

Keep in mind that I am trying to run this in an outlook form. I want to know how to create an object for the setTimout method above. I would even be willing to except an object creation for Wscript.Sleep, but I had no luck with that either as the objects are not readily exposed under outlooks code behind the form. I hope that I have explained enough.
0
BLACK THANOS
Asked:
BLACK THANOS
  • 2
1 Solution
 
ddepastinoCommented:
is idTimer an object? a variable?
Is Windows an object, a control?

assuming Windows and idTimer are objects you need the SET keyword:

SET idTimer = windows.setTimeout("PausedSection", 5000, "VBScript")

the wscript sleep isn't available to the VB IDE to my knowledge, use the sleep API:

Paste the following line at the top of your code/module (right under "option explicit" if it's there:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

then in your code call it up:

Sleep 5000

which is 5 seconds

GL
0
 
Cem TürkSenior Software EngineerCommented:
idTimer = windows.setTimeout("PausedSection", 5000, "VBScript")

should be

 idTimer = window.setTimeout("PausedSection", 5000, "VBScript")
0
 
BLACK THANOSAuthor Commented:
Great responses guys, but not quite what I am looking for. The code that you specified above will not work in outlook forms unless an object is created. Outlook behind the forms is looking for an object to be created. For instance:

Set objApp = CreateObject("Word.Application")
or
Set objApp = CreateObject("Excel.Application")  

exposes the Word and Excel objects in Outlook so the methods are accessible. I was presuming that there would be something to the effect like : set objApp = Createobject("Window.Application) to expose the SetTimeout method. I hope this makes sense.
0
 
ddepastinoCommented:
I assure you this works as I just tried it in an Outlook VBA IDE:

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

That line needs to be placed at the top of whatever you are coding, be it class, module or form.  You can also make this call global by changing the scope and inserting it into a module:

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

To call it up just use:

Sleep 5000

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now