Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I want to export multiple tables into one csv file but manage to keep the headers or have a way to differentiate between them in the output file. I am using the code below:
Sub ExportToExcel
'Get the table we want to export
Set t1 = ActiveDocument.GetSheetObject("CH51")
t1.Export "tables.txt", ","
Set t2 = ActiveDocument.GetSheetObject("CH52")
t2.Export "tables.txt", ",", , TRUE
End Sub
Unfortunatelly what this does is to export the headers only from the first table and ignores the second. Is there any way that I can write a blank line between tables or at least write all the headers?
Cheers
D
You can add a bit of code to open the file and append some text in between. Something like this maybe:
Sub ExportToExcel
'Get the table we want to export
Set t1 = ActiveDocument.GetSheetObject("CH51")
t1.Export "tables.txt", ","
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("tables.txt", 8, True)
objTextFile.WriteLine("")
objTextFile.Close
Set t2 = ActiveDocument.GetSheetObject("CH52")
t2.Export "tables.txt", ",", , TRUE
End Sub