Hi,
Im trying to make a little program for inserting CSV (Comma Separated Value) files in Excel via COM_HANDLING. The point
is that i want to open only once excel, so 1 workbook, create
the necessary sheets, activate and insert the involved CSV files
in the sheets. Creating the Excel appl, and sheets was a piece of cake.
To test the insertion of a CSV file in a particular sheet, i first opened excel, start recording a macro via <tools>,<macro>,<start recording>, then while the macro was running, inserted a CSV file via <data>,<get external data>,<text-file>, chooses the delimiter <semi colon> and begin point and the CSV file was inserted in the appropriated sheet. Then i stopped the macro recorder, which gave me the next VBA code:
/* The VBA code, recorded with a macro is the next : */
With ActiveSheet.QueryTables.Add(Connection:="TEXT;D:\tmp\022000.csv", _
Destination:=Range("A1"))
.Name = "022000"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
End Sub
Next i've tried to translate the QueryTables:Add method to Progress, but that doesn't work. I've opened the Progress Object viewer afterwards, searched for QueryTables, but this didn't help me at all !
/* BEGIN - PROGRESS CODE */
DEF VAR chExcel AS COM-HANDLE NO-UNDO.
/* Create handle to Excel Appl */
CREATE "Excel.Application" chExcel.
/* Show Excel */
chExcel:Visible=true.
/* Open workbook with first CSV file */
chExcel:Workbooks:OPEN("d:\tmp\032000.csv").
/* Create a second sheet */
chExcel:Sheets:ADD.
/* Select new created sheet, which has default label Sheet1 */
chExcel:Sheets("Sheet1"):Select.
/* Insert second csv file in selected sheet */
chExcel:ActiveSheet:QueryTables:ADD(Connection:="TEXT;D:\tmp\022000.csv",Destination:=Range("A1")). /* Doesn't work, howto ? */
/* release the handle */
RELEASE OBJECT chExcel.
/* END - PROGRESS CODE */
Does someone has a clue ?
Greetings,
Emmanuel Nuyttens
Programmer
C&C Computers Oudenaarde.
Im trying to make a little program for inserting CSV (Comma Separated Value) files in Excel via COM_HANDLING. The point
is that i want to open only once excel, so 1 workbook, create
the necessary sheets, activate and insert the involved CSV files
in the sheets. Creating the Excel appl, and sheets was a piece of cake.
To test the insertion of a CSV file in a particular sheet, i first opened excel, start recording a macro via <tools>,<macro>,<start recording>, then while the macro was running, inserted a CSV file via <data>,<get external data>,<text-file>, chooses the delimiter <semi colon> and begin point and the CSV file was inserted in the appropriated sheet. Then i stopped the macro recorder, which gave me the next VBA code:
/* The VBA code, recorded with a macro is the next : */
With ActiveSheet.QueryTables.Add(Connection:="TEXT;D:\tmp\022000.csv", _
Destination:=Range("A1"))
.Name = "022000"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
End Sub
Next i've tried to translate the QueryTables:Add method to Progress, but that doesn't work. I've opened the Progress Object viewer afterwards, searched for QueryTables, but this didn't help me at all !
/* BEGIN - PROGRESS CODE */
DEF VAR chExcel AS COM-HANDLE NO-UNDO.
/* Create handle to Excel Appl */
CREATE "Excel.Application" chExcel.
/* Show Excel */
chExcel:Visible=true.
/* Open workbook with first CSV file */
chExcel:Workbooks:OPEN("d:\tmp\032000.csv").
/* Create a second sheet */
chExcel:Sheets:ADD.
/* Select new created sheet, which has default label Sheet1 */
chExcel:Sheets("Sheet1"):Select.
/* Insert second csv file in selected sheet */
chExcel:ActiveSheet:QueryTables:ADD(Connection:="TEXT;D:\tmp\022000.csv",Destination:=Range("A1")). /* Doesn't work, howto ? */
/* release the handle */
RELEASE OBJECT chExcel.
/* END - PROGRESS CODE */
Does someone has a clue ?
Greetings,
Emmanuel Nuyttens
Programmer
C&C Computers Oudenaarde.