j.collyer
New Member
- Joined
- Jul 4, 2007
- Messages
- 17
So it appears that .CopyFromRecordset works very well from within Excel's VBA. I am calling a recordset against a .mdb file and get a return of 739 records. If .CopyFromRecordset is used in Excel's VBA, Bam! there is all my data I expected from the recordset.
I am trying to create a class object as a wrapper for an object reference to Excel from within AutoCAD's VBA. The class works! I can drive Excel around all over the place, effect values in ranges and change formatting of the cells, and change from worksheet to worksheet.
I tried passing a recordset from one AutoCAD class (wrapper for the .mdb database) to the Excel class. Once the recordset is in the sub of the Excel wrapper class this is the call:
objExcel.objWorksheet.Range("A1") = "Hello World"
objExcel.objWorksheet.Range("A2").CopyFromRecordset rstRecords
'where rstRecords is a populated record set
'verified as full while it was generated in the .mdb wrapper class object
'and then verified as full when passed into the Excel wrapper class object
"A1" takes "Hello World" but then this leaves me with nothing else in the Excel Worksheet from my recordset. I know it is most often a empty recordset problem but checking the rstRecords just before calling .CopyFromRecordset shows that I have 739 records as expected.
No mater how I move the data around I cannot get the external VBA to provide data from the .CopyFromRecordset call. I tried putting the recordset object into the Excel object class insted, same results.
I know some code is warranted here, can do, but I am thinking that some experience will shine the light on the fact that .CopyFromRecordset ONLY WORKS WHEN CALLED FROM WITHIN EXCEL'S VBA????
You might aske "why do you have to call it from AutoCAD's VBA?" I need this AutoCAD VBA application to dynamically create a new Workbook at runtime. As such, I cannot store my recordset call macros in the Excel file. It doesn't exist till AutoCAD creates the Excel object.
I am trying to create a class object as a wrapper for an object reference to Excel from within AutoCAD's VBA. The class works! I can drive Excel around all over the place, effect values in ranges and change formatting of the cells, and change from worksheet to worksheet.
I tried passing a recordset from one AutoCAD class (wrapper for the .mdb database) to the Excel class. Once the recordset is in the sub of the Excel wrapper class this is the call:
objExcel.objWorksheet.Range("A1") = "Hello World"
objExcel.objWorksheet.Range("A2").CopyFromRecordset rstRecords
'where rstRecords is a populated record set
'verified as full while it was generated in the .mdb wrapper class object
'and then verified as full when passed into the Excel wrapper class object
"A1" takes "Hello World" but then this leaves me with nothing else in the Excel Worksheet from my recordset. I know it is most often a empty recordset problem but checking the rstRecords just before calling .CopyFromRecordset shows that I have 739 records as expected.
No mater how I move the data around I cannot get the external VBA to provide data from the .CopyFromRecordset call. I tried putting the recordset object into the Excel object class insted, same results.
I know some code is warranted here, can do, but I am thinking that some experience will shine the light on the fact that .CopyFromRecordset ONLY WORKS WHEN CALLED FROM WITHIN EXCEL'S VBA????
You might aske "why do you have to call it from AutoCAD's VBA?" I need this AutoCAD VBA application to dynamically create a new Workbook at runtime. As such, I cannot store my recordset call macros in the Excel file. It doesn't exist till AutoCAD creates the Excel object.