Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting(creating) XML files using list

Status
Not open for further replies.

Triacona

Technical User
Jun 11, 2009
462
GB
Dear all,

Please help...I'm a bit stuck [sadeyes]

I have the following code to go through a list and create an XML file with each coresponding item in the list as the file name.

Code:
Private Sub CreateAllDummyXmls_Click()
On Error GoTo Err_CreateAllDummyXmls_Click


Dim ExcelDoc As String
Dim oApp As Object
Dim sFullPath As String
Dim i As Integer


Set oApp = CreateObject("Excel.Application")
 
    For i = 0 To ListFileName.ListCount - 1
    
        sFullPath = txtPath & ListFileName.ItemData(i) & ".xml"
        MsgBox sFullPath
        DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel3, ListFileName.ItemData(i), sFullPath, True
                
    Next

Exit_CreateAllDummyXmls_Click:
    Exit Sub

Err_CreateAllDummyXmls_Click:
    MsgBox Err.Description
    Resume Exit_CreateAllDummyXmls_Click
    
End Sub

At the moment I am getting an error
Object Required

Please can someone tell me where I am going wrong.

The txtPath is a field within the form that contains the path of where I want these documents saved.

Thank you so much for your help!! [bigsmile]
Kind regards

Triacona
 
Code:
    For i = 0 To ListFileName.ListCount - 1

Where is ListFileName defined or populated?

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Dear All,

I have found the solution.
I incorrectly named the List.
It is now named ListFileName

I now have a new problem...

I click on the button to create the xmls in the list and it gives me an error, after giving a msgbox of the path and file name it is going to save.
The error is
Cannot update. Database or object is readonly.

Please help!!
Thank you!!

Kind regards

Triacona
 
Dear Greg,

The list: ListFileName is a list in the form.

Thanks for your help [smile]

Maybe you could help with the above problem please...
Thanks [smile]

Kind regards
Triacona
 
just a quick thought.... you haven't got the spreadsheet open while you are trying to run your process have you....

I have had a similar problem when trying to create excel spreadsheets if i have the spreadsheet open that i am trying to write to....
 
Dear MaxieMax,

MS Excel/spreadsheet is not open during this process.


Thanks for your help [bigsmile]

Any other remedies?

It still gives me the same error.

Thank you,

Kind regards

Triacona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top