Events

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 respond to errors or to cancel the operations.
You can identify which map is being used by examining the Map argument.



Private Sub Workbook_AfterXmlExport(ByVal Map As XmlMap, _ 
                                    ByVal Url As String, _
                                    ByVal Result As XlXmlExportResult)

End Sub

Private Sub Workbook_AfterXmlImport(ByVal Map As XmlMap, _ 
                                    ByVal IsRefresh As Boolean, _
                                    ByVal Result As XlXmlImportResult)

End Sub

Private Sub Workbook_BeforeXmlExport(ByVal Map As XmlMap, _ 
                                     ByVal Url As String, _
                                     Cancel As Boolean)

End Sub

Private Sub Workbook_BeforeXmlImport(ByVal Map As XmlMap, _ 
                                     ByVal Url As String, _
                                     ByVal IsRefresh As Boolean, _
                                     Cancel As Boolean)

End Sub


Example

Using comments to display multi-line text in worksheets

Private Sub Workbook_AfterXmlImport(ByVal Map As XmlMap, _ 
               ByVal bIsRefresh As Boolean, _
               ByVal Result As xlXmlImportResult)

Dim rgeCell As Range
Dim objWsh As Worksheet
Dim rgeRange As Range

Set objWsh = ThisWorkbook.Worksheets("Sheet1")
Set objRange = objWsh.ListObjects("List1").ListColumns("name").Range

For Each rgeCell In objRange
   If Not (rgeCell.Comment Is Nothing) Then
       objCell.Comment.Delete
   End If

   objCell.AddComment rgeCell.Offset(0,1).Text
Next
End Sub


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev