Sets the number of milliseconds that a PowerBuilder client waits before canceling an OLE procedure call to the server.

Applies to

OLEObject objects


oleobject.SetAutomationTimeout ( interval )




The name of an OLEObject variable containing the object for which you want to set the timeout period.


A 32-bit signed long integer value (in milliseconds) specifying how long a PowerBuilder client waits before canceling a procedure call. The default value is 300,000 milliseconds (5 minutes). Specifying 0 or a negative value resets interval to the default value.

Return value


Returns 0 if it succeeds and -1 if it fails.


This function passes the value of interval to PowerBuilder's implementation of the IMessageFilter interface and determines how long PowerBuilder tries to complete an OLE procedure call. The value applies only when PowerBuilder is the OLE client, not when PowerBuilder is the OLE server.

Default timeout period

For most situations, you do not need to call SetAutomationTimeout. The default timeout period of five minutes is usually appropriate. Use SetAutomationTimeout to change the default timeout period if you expect a specific OLE request to take longer than five minutes.

If the timeout period is too short, you may get a PowerBuilder application execution error, R0035. In this case, use SetAutomationTimeout to lengthen the timeout period.

If the timeout period expires, runtime error 1037 occurs. You may want to add code to handle this error, which is often the only indication of a hung server. Note that canceling a transaction often causes memory leaks on both the server and the operating system.

The value that you specify with SetAutomationTimeout applies to all OLE transactions in the current session, including calls that relate to other objects.


This example calls the ConnectToObject function to connect to an Excel worksheet and sets a timeout period of 900,000 milliseconds (15 minutes):

OLEObject ole1
integer rs
long interval
interval = 900000
ole1 = create OLEObject
rs = ole1.ConnectToObject("Excel.Application")
rs = ole1.SetAutomationTimeOut(interval)