none
Write XML entry with Excel VBA RRS feed

  • Question

  • Hi guys,

    I made a userform that allows the person to enter entries in the excel spreadsheet.  Everytime that the person clicks on "Submit" button, the entry is added on a new row in the excel spread sheet.  That works perfectly fine.  Now, I would like to also have a XML file in C:\ to record whatever the person enters in the userform.  I know how to do it in C#, but not VBA.  My workplace has access to Excell VBA only.

    This is my macro for the Excel userform:

    Private Sub SubmitCmd_Click()
    'this is to make sure that all fields are selected

        
        'this is for the submit button, when click, data are put on the excel sheet, may have to play with the A4 and the rows (1,0)
        'This button is to add multiple entries.
        ActiveWorkbook.Sheets("Ticket Tracker").Activate
        Range("F1").Select
        Do
           

        ActiveCell.Offset(0, 0) = Date  'this should be the first node
        ActiveCell.Offset(0, 1) = Time  'this is the time node
        ActiveCell.Offset(0, 2) = Environ("USERNAME") 'this is the person who enters the entry
        ActiveCell.Offset(0, 3) = Textbox1 'this is the commend fields'
        ActiveCell.Offset(0, 4) = Textbox2 'this is the action taken

        Call UserForm_Initialize

    End Sub

     

    So basically everything is working fine to put the entries on the excel spreadsheet.  I want the submit button to also add an entry in the XML file located in C: drive (for example: C:\record.xml).

    The node is like this :

    <Entry>
       <Date></Date>
       <Time></Time>
       <Name></Name>
       <Comments></Comments>
       <Action></Action>
    </Entry>

     

    Anyone knows a solution for this?

    thank you.

    Wednesday, February 1, 2012 10:35 PM

Answers