I have two xslt files loaded into my ms access vba. This access database will be passed around so to minimize the xslt files being lost I was wondering if it is possible write the xsl into the vba?
Here is my vba code:
Private Sub btnImport_Click()
Dim strFile As String, strPath As String
' REFERENCE MS XML, v6.0
Dim xmlDoc As New MSXML2.DOMDocument60, xslDoc As New MSXML2.DOMDocument60
Dim newDoc As New MSXML2.DOMDocument60
strPath = "C:\Users\1122335\Desktop\iavms\IAVM XML dump on 2017-01-20\"
strFile = Dir(strPath & "*.xml")
' LOAD XSL ONLY ONCE
xslDoc.Load "C:\Users\1122335\Desktop\secondLoad.xsl"
While strFile <> ""
' REINITIALIZE DOM OBJECTS
Set xmlDoc = New MSXML2.DOMDocument60
Set newDoc = New MSXML2.DOMDocument60
' LOAD XML SOURCE
xmlDoc.Load strPath & strFile
' TRANSFORM SOURCE
xmlDoc.transformNodeToObject xslDoc, newDoc
newDoc.Save "C:\Users\1122335\Desktop\temp.xml"
' APPEND TO TABLES
On Error Resume Next
Application.ImportXML "C:\Users\1122335\Desktop\temp.xml", acAppendData
strFile = Dir()
Wend
' RELEASE DOM OBJECTS
Set xmlDoc = Nothing: Set xslDoc = Nothing: Set newDoc = Nothing
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
strPath = "C:\Users\1122335\Desktop\iavms\IAVM XML dump on 2017-01-20\"
strFile = Dir(strPath & "*.xml")
' LOAD XSL ONLY ONCE
xslDoc.Load "C:\Users\1122335\Desktop\finally.xsl"
While strFile <> ""
' REINITIALIZE DOM OBJECTS
Set xmlDoc = New MSXML2.DOMDocument60
Set newDoc = New MSXML2.DOMDocument60
' LOAD XML SOURCE
xmlDoc.Load strPath & strFile
' TRANSFORM SOURCE
xmlDoc.transformNodeToObject xslDoc, newDoc
newDoc.Save "C:\Users\1122335\Desktop\temp.xml"
' APPEND TO TABLES
On Error Resume Next
Application.ImportXML "C:\Users\1122335\Desktop\temp.xml", acAppendData
strFile = Dir()
Wend
' RELEASE DOM OBJECTS
Set xmlDoc = Nothing: Set xslDoc = Nothing: Set newDoc = Nothing
End Sub