August 2004
Intermediate to advanced
312 pages
8h 30m
English
The Workbook object provides events that occur before and after data is imported or exported through an XML map. You can use these events to control how the import/export occurs, respond to errors, or cancel the operation.
For example, the following event procedures display information about import and export actions as they occur:
Private Sub Workbook_BeforeXmlImport(ByVal Map As XmlMap, _
ByVal Url As String, ByVal IsRefresh As Boolean, Cancel As Boolean)
Debug.Print "BeforeImport", Map, Url, IsRefresh, Cancel
End Sub
Private Sub Workbook_BeforeXmlExport(ByVal Map As XmlMap, _
ByVal Url As String, Cancel As Boolean)
Debug.Print "BeforeExport", Map, Url, IsRefresh, Cancel
End Sub
Private Sub Workbook_AfterXmlImport(ByVal Map As XmlMap, _
ByVal IsRefresh As Boolean, ByVal Result As XlXmlImportResult)
Debug.Print "AfterImport", Map, Url, Result
End Sub
Private Sub Workbook_AfterXmlExport(ByVal Map As XmlMap, _
ByVal Url As String, ByVal Result As XlXmlExportResult)
Debug.Print "AfterExport", Map, Url, Result
End SubTo cancel an import or export action, set the event’s Cancel argument to True. The following code allows the user to cancel refreshing or importing data from the Orders_Map:
Private Sub Workbook_BeforeXmlImport(ByVal Map As XmlMap, _ ByVal Url As String, ByVal IsRefresh As Boolean, Cancel As Boolean) If Map.name = "Orders_Map" And Not IsRefresh Then res = MsgBox("This action will replace all the data " & _ "in this list. Do you ...