Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default read xml and fill valuesin excel form combobox

Dear friend,
i have created form in excel macros
i have one combobox in my excel form. i need to read my xml which is in
"c:\default.xml" and have to display the values in combobox.
..in my xml i need to take loop the " name" node and display all the names
which is in my xml.so please help me to achive my requirement.please show
some example for thi splease
can any one give vba code to read xml vaues please
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default read xml and fill valuesin excel form combobox

XML files are text files. The code below can read text files. You need to
write code that will filter the XML files and extract the data you are
looking for. If you post the XML data I can help you write the filter


Sub Gettext()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TxtDirectory = "C:\temp\"
Const ReadFileName = "test.xml"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fsread = CreateObject("Scripting.FileSystemObject")
ReadPathName = TxtDirectory & ReadFileName
Set fread = fsread.GetFile(ReadPathName)
Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault)

RowCount = 1
Do While tsread.atendofstream = False

InputLine = tsread.ReadLine
'add filter code here
Loop
tsread.Close

End Sub

"born2achieve" wrote:

Dear friend,
i have created form in excel macros
i have one combobox in my excel form. i need to read my xml which is in
"c:\default.xml" and have to display the values in combobox.
.in my xml i need to take loop the " name" node and display all the names
which is in my xml.so please help me to achive my requirement.please show
some example for thi splease
can any one give vba code to read xml vaues please

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default read xml and fill valuesin excel form combobox

dear friend, this is my xml, , here i need to read the name and display in
combobox pleasehelp me

<?xml version="1.0"?
<data
<student
<id1</id
<nameRaymond</name
<age11</age
<mark0</mark
<designationengneer</designation
</student


<student<id2</id
<nameMoon</name
<age11</age
<mark100</mark
<designationblody</designation
</student


<student<id3</id
<nameBilly</name
<age11</age
<mark100</mark
<designationpassd</designation
</student


<student<id4</id
<namePan</name
<age12</age
<mark80</mark
<designationvhonr</designation
</student


<student<id5</id
<nameQueenie</name
<age10</age
<mark90</mark
<designationsogjg</designation
</student


</data
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default read xml and fill valuesin excel form combobox


Sub Gettext()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TxtDirectory = "C:\temp\test\"
Const ReadFileName = "test.xml"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Set fsread = CreateObject("Scripting.FileSystemObject")
ReadPathName = TxtDirectory & ReadFileName
Set fread = fsread.GetFile(ReadPathName)
Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault)

Do While tsread.atendofstream = False

inputline = tsread.ReadLine
If Left(inputline, 6) = "<name" Then
newname = Mid(inputline, 7)
newname = Left(newname, InStr(newname, "<") - 1)
ActiveSheet.ComboBox1.AddItem newname
End If
'add filter code here
Loop
tsread.Close

End Sub

"born2achieve" wrote:

dear friend, this is my xml, , here i need to read the name and display in
combobox pleasehelp me

<?xml version="1.0"?
<data
<student
<id1</id
<nameRaymond</name
<age11</age
<mark0</mark
<designationengneer</designation
</student


<student<id2</id
<nameMoon</name
<age11</age
<mark100</mark
<designationblody</designation
</student


<student<id3</id
<nameBilly</name
<age11</age
<mark100</mark
<designationpassd</designation
</student


<student<id4</id
<namePan</name
<age12</age
<mark80</mark
<designationvhonr</designation
</student


<student<id5</id
<nameQueenie</name
<age10</age
<mark90</mark
<designationsogjg</designation
</student


</data

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default read xml and fill valuesin excel form combobox

Dear friend, excellent.your code works fine
and i want to share the code that i have found also.


dim articleDoc As New DOMDocument
Dim sections As IXMLDOMNodeList
Dim sectionNode As IXMLDOMNode
Dim s As String
articleDoc.async = False
articleDoc.Load ("C:\default.xml")
'Me.Caption = articleDoc.selectSingleNode("//student/name").Text

Set sections = articleDoc.selectNodes("//student")
ComboBox1.Clear

For Each sectionNode In sections
ComboBox1.AddItem (sectionNode.selectSingleNode("name").Text)
Next
ComboBox1.ListIndex = 0

so i got two solutions.very happy friend
i have one more help .
i need to import this xml to my excel workbook using macros can u please
show me some sample code please


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default read xml and fill valuesin excel form combobox

I added activesheet in front of combox1. Also added library references as
stated below

On the Project menu, click References. Select the type libraries for
Microsoft ActiveX Data Object 2.5 (or later) and Microsoft XML 3.0.

Sub test()

Dim articleDoc As New DOMDocument
Dim sections As IXMLDOMNodeList
Dim sectionNode As IXMLDOMNode
Dim s As String
articleDoc.async = False
articleDoc.Load ("C:\temp\test\test.xml")
'Me.Caption = articleDoc.selectSingleNode("//student/name").Text

Set sections = articleDoc.selectNodes("//student")
ActiveSheet.ComboBox1.Clear

For Each sectionNode In sections
ActiveSheet.ComboBox1.AddItem
(sectionNode.selectSingleNode("name").Text)
Next
ActiveSheet.ComboBox1.ListIndex = 0

End Sub


"born2achieve" wrote:

Dear friend, excellent.your code works fine
and i want to share the code that i have found also.


dim articleDoc As New DOMDocument
Dim sections As IXMLDOMNodeList
Dim sectionNode As IXMLDOMNode
Dim s As String
articleDoc.async = False
articleDoc.Load ("C:\default.xml")
'Me.Caption = articleDoc.selectSingleNode("//student/name").Text

Set sections = articleDoc.selectNodes("//student")
ComboBox1.Clear

For Each sectionNode In sections
ComboBox1.AddItem (sectionNode.selectSingleNode("name").Text)
Next
ComboBox1.ListIndex = 0

so i got two solutions.very happy friend
i have one more help .
i need to import this xml to my excel workbook using macros can u please
show me some sample code please

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
Adding to excel user form combobox Gimp Excel Programming 3 January 26th 07 05:02 PM
Fill a combobox on a form from a txt file Daniel Bonallack Excel Programming 2 April 4th 05 07:49 PM
Getting the 2nd largest or smallest valuesin a range Michael Rekas Excel Discussion (Misc queries) 5 January 31st 05 07:48 AM
Excel 2000 VBA Form Combobox value Matt. Excel Programming 2 July 25th 03 06:37 PM


All times are GMT +1. The time now is 09:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"