Pages

Monday, July 25, 2011

Export Access Table to excel Workbook

If you have an access database with multiple tables and you want to export select any table then export it to excel worksheet.

Download the file



Here is the code-

Option Compare Database


Private Sub Combo15_Change()
' set row source type to table/query
' and type SELECT Name FROM MSysObjects WHERE Type=1 AND Flags=0; in row source
'this will set wrokbook name same as table which is selcted to export
Me.Text17.Value = Me.Combo15.Value
End Sub

Private Sub Command0_Click()
'****************************** to add table names to combo box*******************

' set row source type to table/query
' and type SELECT Name FROM MSysObjects WHERE Type=1 AND Flags=0; in row source

'tool -> reference -> Microsoft Office 12.0 Object Library
Dim fldpth As String
'it will open the dialogbox and choose folder in which all workbooks are saved.
Application.FileDialog(msoFileDialogFolderPicker).Title = "Choose Folder"
Application.FileDialog(msoFileDialogFolderPicker).Show
fldpth = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\"

Me.Text21 = fldpth
End Sub

Private Sub Command23_Click()
' it will export your access table to excel
DoCmd.TransferSpreadsheet acExport, , Me.Combo15.Value, Me.Text21.Value & Me.Text17.Value & Me.Combo19.Value, True
MsgBox "Table Successfully Exported to Excel workbook"
End Sub


Access Macro File - http://www.filefactory.com/file/cc91c31/n/Export_a_table_from_access_to_excel.accdb

No comments:

Post a Comment