I'm writing a function in vba which can take in string parameters, and use it in xPath
thus query specificed data.
Public Function GetVal(ByVal refNum As String, ByVal jobNum As String, ByVal readingNum As String, ByVal dataName As String) As String
Dim xDoc As MSXML2.DOMDocument
Dim xmlFilePath As String: xmlFilePath = ThisWorkbook.Path & "\1.xml"
Dim apath as String
If Not xDoc.Load(xmlFilePath) Then
MsgBox ("Failed to load XML file."), vbCritical, "Sub Aborted"
aPath = "//CasaPiezos[CasaPiezo/CasaPiezoRdg/'dataname'"
'above is line not working i replace the variable with string it works, but string name canot
'those quotes driving me crazy.....
GetVal = xDoc.SelectSingleNode(aPath).Text
Pinned topic problem pass string variable to a xPath in VBA
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-09-25T17:08:39Z at 2012-09-25T17:08:39Z by SystemAdmin