gooker Posted January 3, 2008 Share Posted January 3, 2008 (edited) IT'S ABOUT ACCESS TO EXCEL.Public Function ExportTableToOneExcel(ByVal AccName As String, ByVal ExpExcelName As String, Optional tableName As String = "", Optional DbPassWord As String = "") Dim i As Long Dim rstSchema As ADODB.Recordset Dim accApp As Access.Application Dim cnnTemp As ADODB.Connection Set accApp = New Access.Application accApp.OpenCurrentDatabase AccName, , DbPassWord Set cnnTemp = accApp.CurrentProject.Connection Set rstSchema = cnnTemp.OpenSchema(adSchemaTables) Do Until rstSchema.EOF If rstSchema("TABLE_TYPE") = "TABLE" Then For i = 0 To rstSchema.Fields.Count - 1 If rstSchema(i).Name = "TABLE_NAME" Then If tableName <> "" Then If rstSchema.Fields(i).Value = tableName Then accApp.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, tableName, ExpExcelName, True Exit Do End If Else accApp.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, rstSchema.Fields(i).Value, ExpExcelName, True End If End If Next End If rstSchema.MoveNext Loop rstSchema.Close Set cnnTemp = Nothing accApp.CloseCurrentDatabase Set accApp = Nothing End Function Edited January 3, 2008 by gooker Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 3, 2008 Share Posted January 3, 2008 AutoIt is more like VBScript that VB (or VB.NET), but here's an untested shot at it: Func ExportTableToOneExcel($AccName, $ExpExcelName, $tableName = "", $DbPassWord = "") Local $i, $rstSchema, $accApp, $cnnTemp Local $adSchemaTables, $acExport, $acSpreadsheetTypeExcel9 ; <-- Where are these set??? $accApp = ObjCreate("Access.Application") $accApp.OpenCurrentDatabase($AccName, "", $DbPassWord) $cnnTemp = $accApp.CurrentProject.Connection $rstSchema = $cnnTemp.OpenSchema($adSchemaTables) Do If $rstSchema("TABLE_TYPE") = "TABLE" Then For $i = 0 To $rstSchema.Fields.Count - 1 If $rstSchema($i).Name = "TABLE_NAME" Then If $tableName <> "" Then If $rstSchema.Fields($i).Value = $tableName Then $accApp.DoCmd.TransferSpreadsheet($acExport, $acSpreadsheetTypeExcel9, $tableName, $ExpExcelName, True) ExitLoop EndIf Else $accApp.DoCmd.TransferSpreadsheet($acExport, $acSpreadsheetTypeExcel9, $rstSchema.Fields($i).Value, $ExpExcelName, True) EndIf EndIf Next EndIf $rstSchema.MoveNext Until $rstSchema.EOF $rstSchema.Close $cnnTemp = "" $accApp.CloseCurrentDatabase $accApp = "" EndFunc ;==>ExportTableToOneExcel I had no idea what to make of these variables: $adSchemaTables, $acExport, $acSpreadsheetTypeExcel9 Probably won't work, but might be a starting point. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gooker Posted January 4, 2008 Author Share Posted January 4, 2008 AutoIt is more like VBScript that VB (or VB.NET), but here's an untested shot at it: Func ExportTableToOneExcel($AccName, $ExpExcelName, $tableName = "", $DbPassWord = "") Local $i, $rstSchema, $accApp, $cnnTemp Local $adSchemaTables, $acExport, $acSpreadsheetTypeExcel9 ; <-- Where are these set??? $accApp = ObjCreate("Access.Application") $accApp.OpenCurrentDatabase($AccName, "", $DbPassWord) $cnnTemp = $accApp.CurrentProject.Connection $rstSchema = $cnnTemp.OpenSchema($adSchemaTables) Do If $rstSchema("TABLE_TYPE") = "TABLE" Then For $i = 0 To $rstSchema.Fields.Count - 1 If $rstSchema($i).Name = "TABLE_NAME" Then If $tableName <> "" Then If $rstSchema.Fields($i).Value = $tableName Then $accApp.DoCmd.TransferSpreadsheet($acExport, $acSpreadsheetTypeExcel9, $tableName, $ExpExcelName, True) ExitLoop EndIf Else $accApp.DoCmd.TransferSpreadsheet($acExport, $acSpreadsheetTypeExcel9, $rstSchema.Fields($i).Value, $ExpExcelName, True) EndIf EndIf Next EndIf $rstSchema.MoveNext Until $rstSchema.EOF $rstSchema.Close $cnnTemp = "" $accApp.CloseCurrentDatabase $accApp = "" EndFunc ;==>ExportTableToOneExcel I had no idea what to make of these variables: $adSchemaTables, $acExport, $acSpreadsheetTypeExcel9 Probably won't work, but might be a starting point. ths Link to comment Share on other sites More sharing options...
ptrex Posted January 4, 2008 Share Posted January 4, 2008 (edited) @all Just to fill in the missing parts. Func ExportTableToOneExcel($AccName, $ExpExcelName, $tableName = "", $DbPassWord = "") Const $adSchemaTables = 20 Const $acExport = 1 Const $acSchemaXSD = 1 Const $acSpreadsheetTypeExcel9 = 8 Local $i, $rstSchema, $accApp, $cnnTemp Local $adSchemaTables, $acExport, $acSpreadsheetTypeExcel9 ; <-- Where are these set??? $accApp = ObjCreate("Access.Application") $accApp.OpenCurrentDatabase($AccName, "", $DbPassWord) $cnnTemp = $accApp.CurrentProject.Connection $rstSchema = $cnnTemp.OpenSchema($adSchemaTables) Do If $rstSchema("TABLE_TYPE") = "TABLE" Then For $i = 0 To $rstSchema.Fields.Count - 1 If $rstSchema($i).Name = "TABLE_NAME" Then If $tableName <> "" Then If $rstSchema.Fields($i).Value = $tableName Then $accApp.DoCmd.TransferSpreadsheet($acExport, $acSpreadsheetTypeExcel9, $tableName, $ExpExcelName, True) ExitLoop EndIf Else $accApp.DoCmd.TransferSpreadsheet($acExport, $acSpreadsheetTypeExcel9, $rstSchema.Fields($i).Value, $ExpExcelName, True) EndIf EndIf Next EndIf $rstSchema.MoveNext Until $rstSchema.EOF $rstSchema.Close $cnnTemp = "" $accApp.CloseCurrentDatabase $accApp = "" EndFunc ;==>ExportTableToOneExcel regards ptrex Edited January 4, 2008 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 4, 2008 Share Posted January 4, 2008 @all Just to fill in the missing parts. Func ExportTableToOneExcel($AccName, $ExpExcelName, $tableName = "", $DbPassWord = "") Const $adSchemaTables = 20 Const $acExport = 1 Const $acSchemaXSD = 1 Const $acSpreadsheetTypeExcel9 = 8 Local $i, $rstSchema, $accApp, $cnnTemp Local $adSchemaTables, $acExport, $acSpreadsheetTypeExcel9 ; <-- Where are these set??? $accApp = ObjCreate("Access.Application") $accApp.OpenCurrentDatabase($AccName, "", $DbPassWord) $cnnTemp = $accApp.CurrentProject.Connection $rstSchema = $cnnTemp.OpenSchema($adSchemaTables) ; ... EndFunc ;==>ExportTableToOneExceloÝ÷ Ú· j·l¦ÚÞÇú®¢×¢{-j{lßt¡¢H².ØZ½é'£ í¢Z(ú+¶ëh"ÚÞ}êÞÇ®® It might actually work now! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now