Export (0) Print
Expand All

Refresh Method

Office 2003

Refreshes data from the connection specified in the <ConnectionInfo Purpose="Query"> section of a given binding and updates the data displayed for the corresponding schema map. Returns an error if the specified data binding does not contain a valid connection or query definition.

expression .Refresh(ShowDialogs, varParamNameValList)

expression    An expression that returns an XmlDataBinding object.

ShowDialogs     Optional Boolean. Specifies whether a dialog box is displayed if the Refresh method encounters an error that is returned by the Spreadsheet component itself. When ShowDialogs    is set to True, a dialog box is displayed if the Refresh method encounters an error returned by the Spreadsheet component. When ShowDialogs is set to False, dialog boxes for Spreadsheet component errors are not displayed. The default is False.

The ShowDialogs argument also controls whether a confirmation dialog box is displayed if the connection specifies an update binding (<ConnectionInfo Purpose="Update">) and the data in the spreadsheet has been changed by the user. When the ShowDialogs argument is set to True, a dialog box is displayed informing the user that data has been changed and asking whether to update the data source. When the ShowDialogs argument is set to False, no dialog box is displayed and data is updated without confirmation.

Note  The ShowDialogs argument does not control whether a dialog box will be displayed for errors external to the Spreadsheet component, such as errors returned by scripting components. To prevent a dialog box from displaying for errors external to the Spreadsheet component, you must trap those errors in your script.

varParamNameValList    Optional. If the binding query contains client parameters, they can be passed in an array of name/value pair arrays. For example: XmlDataBindings("Binding1").Refresh(True, Array(Array(Param1, Value1), Array(Param2, Value2)). If a parameter is not specified, the value specified in the /ClientParameterBindings/ClientParameterBinding/@DefaultValue attribute of the binding definition will be used.

Remarks

When a Refresh method call succeeds, the BindingCompleted event will fire.

When a Refresh method call fails, the BindingError event will fire and, if the ShowDialogs argument is set to True, a dialog box will be displayed. To catch the error in script, you must create an event procedure for the BindingError event. The error will not be returned by the Refresh method or the browser.

When the Refresh method is called on an asynchronous binding, it returns immediately. You can use the Async property of the XmlDataBinding object to determine if a binding supports asynchronous binding. You can write event procedures for the BindingCompleted and BindingError events to determine when the binding is finished. When the Refresh method is called on a synchronous binding, any attempt to call the Refresh method or any other members of the XmlDataBinding object will be blocked if the synchronous binding is in progress.

You can use the BindingInProgress property of the XmlDataBinding object to determine if asynchronous binding is in progress. However, because calls to XmlDataBinding members are blocked while a synchronous binding is in progress, you can effectively use the BindingInProgress property to check the status of both synchronous and asynchronous bindings. For example, this loop:

        Do
' Loop until binding operation is complete.
Loop While objBinding.BindingInProgress = True

      

will work to determine if binding is in progress for either kind of binding. This is because the loop will return False as long as a synchronous binding is in progress because all XmlDataBinding object calls are blocked during synchronous binding. And, it will also return False while asynchronous binding is in progress, because that is explicitly what the BindingInProgress property is designed to do.

Refreshes the specified object (reloads source data or repaints the object).

expression .Refresh()

expression    An expression that returns an object in the Applies To list.

Example

The following example uses the Refresh method to refresh a data binding, which causes an event handler for the BindingCompleted event to trap the event and run code.

        Sub RefreshBinding(Spreadsheet1)
    Spreadsheet1.ActiveWorkbook.XmlDataBindings.Item(1).Refresh
End Sub

Sub Spreadsheet1_BindingCompleted(bindingID, Action)

    If Spreadsheet1.ActiveWorkbook.XmlDataBindings.Item(bindingID).CanQuery = True Then
        ' Write code here to perform any additional actions on this query binding.
    End If

End Sub
      

Note  For information on trapping the BindingCompleted event from script running in a Web page, see the BindingCompleted event topic.

This example causes the chart workspace to repaint itself.

ChartSpace1.Refresh
			
		


See Also | Repaint Method


Show:
© 2015 Microsoft