Objeto XPath (Excel)

Representa um XPath mapeado para um objeto Range ou ListColumn .

Comentários

Use o método SetValue para mapear um XPath para uma coluna da lista ou intervalo. O método SetValue também é usado para alterar as propriedades de um XPath existente.

Use o método Clear para remover um XPath que tenha sido mapeado para uma coluna da lista ou intervalo.

Exemplo

O exemplo a seguir cria uma lista XML com base no mapa de esquema Contatos anexado à pasta de trabalho e, em seguida, usa o método SetValue para associar cada coluna a um XPath.

Sub CreateXMLList() 
 Dim mapContact As XmlMap 
 Dim strXPath As String 
 Dim lstContacts As ListObject 
 Dim lcNewCol As ListColumn 
 
 ' Specify the schema map to use. 
 Set mapContact = ActiveWorkbook.XmlMaps("Contacts") 
 
 ' Create a new list. 
 Set lstContacts = ActiveSheet.ListObjects.Add 
 
 ' Specify the first element to map. 
 strXPath = "/Root/Person/FirstName" 
 ' Map the element. 
 lstContacts.ListColumns(1).XPath.SetValue mapContact, strXPath 
 
 ' Specify the element to map. 
 strXPath = "/Root/Person/LastName" 
 ' Add a column to the list. 
 Set lcNewCol = lstContacts.ListColumns.Add 
 ' Map the element. 
 lcNewCol.XPath.SetValue mapContact, strXPath 
 
 strXPath = "/Root/Person/Address/Zip" 
 Set lcNewCol = lstContacts.ListColumns.Add 
 lcNewCol.XPath.SetValue mapContact, strXPath 
End Sub

Métodos

Propriedades

Confira também

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.