Dear all,
Please help...I'm a bit stuck
I want the following code to go through a list and create an XML file with each coresponding item in the list as the file name.
The list name is ListFileName.
At the moment I am getting an error
The txtPath is a field within the form that contains the path of where I want these documents saved.
MS Excel workbook/spreadsheet is not open during this process.
I have tried a few variations to achieve the result (below).
Please help...
Thank you so much for your forthcoming help!!
Kind regards
Triacona
Please help...I'm a bit stuck
I want the following code to go through a list and create an XML file with each coresponding item in the list as the file name.
The list name is ListFileName.
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
Please can someone tell me where I am going wrong.Cannot update. Database or object is readonly
The txtPath is a field within the form that contains the path of where I want these documents saved.
MS Excel workbook/spreadsheet is not open during this process.
I have tried a few variations to achieve the result (below).
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) & ".RTF"
sFullPath = txtPath & ListFileName.ItemData(i) & ".xml"
MsgBox sFullPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel3, ListFileName.ItemData(i), sFullPath, False
'DoCmd.OutputTo acOutputFunction, ListFileName.ItemData(i), acformatXML, sFullPath, False
'DoCmd.OutputTo acOutputQuery, ListFileName.ItemData(i), acFormatRTF, sFullPath, True
'DoCmd.OutputTo acOutputTable, ListFileName.ItemData(i), acUTF16, sFullPath, True
'DoCmd.TransferDatabase acExport, acSchemaXSD, ListFileName.ItemData(i), sFullPath, True
'DoCmd.OutputTo acOutputTable, ListFileName.ItemData(i), acformatXML, sFullPath, False
'DoCmd.Save , ListFileName.ItemData(i)
'DoCmd.OutputTo acOutput, ListFileName.ItemData(i), acformatUTF16, sFullPath, False
Next
Exit_CreateAllDummyXmls_Click:
Exit Sub
Err_CreateAllDummyXmls_Click:
MsgBox Err.Description
Resume Exit_CreateAllDummyXmls_Click
End Sub
Thank you so much for your forthcoming help!!
Kind regards
Triacona