I was write code for excel vba xml database values write into text file. when i using without any special characters xml values parsed into their text file without any issues but when i using special characters xml cannot parse special characters (&,- etc) error getting on my macro page. Anyone have any ideas on how to resolve this?

Dim XDoc1 As Object
Dim XHTML1 As IHTMLElement
Dim XURL1 As String
Dim CustomerName1 As String

Set XDoc1 = CreateObject("MSXML2.DOMDocument")
XDoc1.async = False: XDoc1.validateOnParse = False
XDoc1.Load ("http://www.beamon.com/windows_application/macro1.php" + "?Id=" + Sheets(1).Range("D2"))
Set Lists = XDoc1.DocumentElement
Set getFirstChild = Lists.FirstChild
Set getCustomerName1 = Lists.ChildNodes(1)
Set getEnglname = Lists.ChildNodes(2)
Set getTopCustomer = Lists.ChildNodes(3)
Set getTopAssy = Lists.ChildNodes(4)
Set getTopFab = Lists.ChildNodes(5)
Set getTopnew1 = Lists.ChildNodes(6)
Set getTopnew2 = Lists.ChildNodes(7)
Set getTopside = Lists.ChildNodes(8)
Set getBotCustomer = Lists.ChildNodes(9)
Set getBotAssy = Lists.ChildNodes(10)
Set getBotFab = Lists.ChildNodes(11)
Set getBotnew1 = Lists.ChildNodes(12)
Set getBotnew2 = Lists.ChildNodes(13)
Set getBotside = Lists.ChildNodes(14)

Sheets(1).Range("T5") = getCustomerName1.text
Sheets(1).Range("T6") = getFirstChild.text & Space(1) & getEnglname.text
Sheets(1).Range("T7") = getTopCustomer.text
Sheets(1).Range("T8") = getTopAssy.text
Sheets(1).Range("T9") = getTopFab.text
Sheets(1).Range("T10") = getTopnew1.text
Sheets(1).Range("T11") = getTopnew2.text
Sheets(1).Range("T12") = getTopside.text

Sheets(1).Range("T13") = getBotCustomer.text
Sheets(1).Range("T14") = getBotAssy.text
Sheets(1).Range("T15") = getBotFab.text
Sheets(1).Range("T16") = getBotnew1.text
Sheets(1).Range("T17") = getBotnew2.text
Sheets(1).Range("T18") = getBotside.text
Columns("T").EntireColumn.Hidden = True
Set XDoc1 = Nothing

Dim rng As Range
Dim c As Range
Dim FF

FF = FreeFile
Open "C:\Area ratio\etch.txt" For Output As #FF
Set rng = Range("T5:T18")
For Each c In rng.Cells
Write #FF, c.Value
Next c
Close #FF

1 Month
Discussion Span
Last Post by rproffitt

To move things along, does this happen before or after the Open statement?
In other words, time for you to debug where this happens, what line and then focus on that line.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.