Consulting

Results 1 to 6 of 6

Thread: xml to vba listbox

  1. #1
    VBAX Regular
    Joined
    Oct 2007
    Posts
    9
    Location

    Question xml to vba listbox

    Hi ppl!

    I am trying to develop an excel workbook that should have a listbox that have to be populated from a xml file.

    I have searched millions of sites, foruns, and can't get no example that works.

    Can anyone help me?

    Thanks anyway.

  2. #2
    VBAX Tutor
    Joined
    Aug 2007
    Posts
    273
    Location
    i have not done anything with xml files, but a here are a few sites that might help

    http://www.ozgrid.com/forum/showthread.php?t=27818
    http://en.allexperts.com/q/XML-1469/...iles-Excel.htm

    from the little bit that i read it looks like it might be easyest to bring the data into excel then load it into the listbox. it would help if i knew what the xml file you were using looked like. also is the list box an object on the sheet or are you using data validation to turn a cell into a listbox?

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,455
    Location
    How about just reading it in VBA, it s just a text file, and pase the data and load the listbox from there.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Oct 2007
    Posts
    9
    Location

    Thumbs up

    Hi vba ppl!

    I have found something that are working:

    [vba]
    Sub ler_xml()
    Dim xmldoc As MSXML2.DOMDocument
    Set xmldoc = New MSXML2.DOMDocument
    Dim root As IXMLDOMElement
    Dim oNodeList As IXMLDOMNodeList
    Dim item As IXMLDOMNode
    Dim subitem As IXMLDOMNode
    Dim myarray As Variant

    xmldoc.async = False
    xmldoc.Load ("c:\T-Pedidos\Obras.xml")
    Set root = xmldoc.documentElement
    Set oNodeList = root.childNodes

    For Each item In oNodeList
    UserForm2.ListBox1.AddItem (item.childNodes.item(1).Text & " | " & item.childNodes.item(2).Text & " | " & item.childNodes.item(3).Text)

    Next
    End Sub
    [/vba]

    Right now i am searching for a way to perform a search/filter in a userform/listbox.

    If somebody knows how please tell me.

    Good Codes For Everybody!

  5. #5
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Quote Originally Posted by cavacuz
    Right now i am searching for a way to perform a search/filter in a userform/listbox.

    If somebody knows how please tell me.
    If you design your listbox to be more of a 'results' box, you can use xPath for searches and filters. .02 Stan

  6. #6
    VBAX Regular
    Joined
    Oct 2007
    Posts
    9
    Location
    Quote Originally Posted by stanl
    If you design your listbox to be more of a 'results' box, you can use xPath for searches and filters. .02 Stan
    Hi stan!

    What i am trying to do is perform a search/filter in a listbox populated from a xml.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •