By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,222 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,222 IT Pros & Developers. It's quick & easy.

VBA Macro XML receiving Run-time error '91': Object variable or With block variable n

P: 2
I was write code for Excel VBA XLM 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?

My code :-
Expand|Select|Wrap|Line Numbers
  1. Dim XDoc1 As Object
  2. Dim XHTML1 As IHTMLElement
  3. Dim XURL1 As String
  4. Dim CustomerName1 As String
  5.  
  6. Set XDoc1 = CreateObject("MSXML2.DOMDocument")
  7. XDoc1.async = False: XDoc1.validateOnParse = False
  8. XDoc1.Load ("http://www.beamon.com/windows_application/macro1.php" + "?Id="   + Sheets(1).Range("D2"))
  9. Set Lists = XDoc1.DocumentElement
  10. Set getFirstChild = Lists.FirstChild
  11. Set getCustomerName1 = Lists.ChildNodes(1)
  12. Set getEnglname = Lists.ChildNodes(2)
  13. Set getTopCustomer = Lists.ChildNodes(3)
  14. Set getTopAssy = Lists.ChildNodes(4)
  15. Set getTopFab = Lists.ChildNodes(5)
  16. Set getTopnew1 = Lists.ChildNodes(6)
  17. Set getTopnew2 = Lists.ChildNodes(7)
  18. Set getTopside = Lists.ChildNodes(8)
  19. Set getBotCustomer = Lists.ChildNodes(9)
  20. Set getBotAssy = Lists.ChildNodes(10)
  21. Set getBotFab = Lists.ChildNodes(11)
  22. Set getBotnew1 = Lists.ChildNodes(12)
  23. Set getBotnew2 = Lists.ChildNodes(13)
  24. Set getBotside = Lists.ChildNodes(14)
  25.  
  26. Sheets(1).Range("T5") = getCustomerName1.text
  27. Sheets(1).Range("T6") = getFirstChild.text & Space(1) & getEnglname.text
  28. Sheets(1).Range("T7") = getTopCustomer.text
  29. Sheets(1).Range("T8") = getTopAssy.text
  30. Sheets(1).Range("T9") = getTopFab.text
  31. Sheets(1).Range("T10") = getTopnew1.text
  32. Sheets(1).Range("T11") = getTopnew2.text
  33. Sheets(1).Range("T12") = getTopside.text
  34.  
  35. Sheets(1).Range("T13") = getBotCustomer.text
  36. Sheets(1).Range("T14") = getBotAssy.text
  37. Sheets(1).Range("T15") = getBotFab.text
  38. Sheets(1).Range("T16") = getBotnew1.text
  39. Sheets(1).Range("T17") = getBotnew2.text
  40. Sheets(1).Range("T18") = getBotside.text
  41. Columns("T").EntireColumn.Hidden = True
  42. Set XDoc1 = Nothing
  43.  
  44. Dim rng As Range
  45. Dim c As Range
  46. Dim FF
  47.  
  48. FF = FreeFile
  49. Open "C:\Area ratio\etch.txt" For Output As #FF
  50. Set rng = Range("T5:T18")
  51. For Each c In rng.Cells
  52. Write #FF, c.Value
  53. Next c
  54. Close #FF
Apr 5 '17 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.