none
export xml string from ms-access to xml file encoding "utf-8". RRS feed

  • Question

  • I have an XML string that was operated in SQL server. after retrieving the XML string into ms-access by a pass-through query I want to export it to an XML file encoding "utf-8".

    Can anyone give the vba code for this?

    Thanks ahead

    Saturday, August 12, 2017 1:40 PM

All replies

  • Have you looked at Application.ExportXML in the help file?

    If that doesn't work for you: the MSXML library provides a great deal of power to shape exactly what you want.


    -Tom. Microsoft Access MVP


    Saturday, August 12, 2017 4:27 PM
  • Hi,

    Also, depending on what the data looks like in Access after you have imported it from SQL Server, maybe you can  use the Open For Output statement or FSO to simply write the XML data into a file on your computer.

    Just a thought...

    Saturday, August 12, 2017 7:36 PM
  • Hi focus10,

    As already suggested by the community members, you can try to use Application.ExportXML Method.

    VBA code example:

    Sub ExportCustomerOrderData() 
     Dim objOrderInfo As AdditionalData 
     Dim objOrderDetailsInfo As AdditionalData 
    
     Set objOrderInfo = Application.CreateAdditionalData 
    
     ' Add the Orders and Order Details tables to the data to be exported. 
     Set objOrderDetailsInfo = objOrderInfo.Add("Orders") 
     objOrderDetailsInfo.Add "Order Details" 
    
     ' Export the contents of the Customers table. The Orders and Order 
     ' Details tables will be included in the XML file. 
     Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _ 
     DataTarget:="Customer Orders.xml", _ 
     AdditionalData:=objOrderInfo 
    End Sub

    Reference:

    Application.ExportXML Method (Access)

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Monday, August 14, 2017 1:55 AM
    Moderator