Saturday, 18 April 2015

How to Export All MS Access Tables Data to Excel

Exporting All MS Access Tables Data Into to Excel Through VBA Macro
'This Macro Ignores or Skip the System Tables.
Sub Exp_Data2Excel()
Dim OP_FileName As String

'Captruring Current Database Name
CurDB_Name = Left(CurrentProject.Name, Len(CurrentProject.Name) - 6)

'Defining Output File Name
OP_FileName = CurrentProject.Path & "\" & CurDB_Name & "-" & Format(Date, "DDMMMYYYY") & ".xlsx"

Dim Tbl As Object
Dim DB As Object

Set DB = CurrentDb
Set Tbl = DB.TableDefs

For Each Tbl In DB.TableDefs
'Skipping System Tables
If Not (Tbl.Name Like "MSys*" Or Tbl.Name Like "~*") Then
Tbl_Name = Tbl.Name
'Exporting Each User Defined Table as a Sheet into Output File
DoCmd.TransferSpreadsheet acExport, , Tbl_Name, OP_FileName, True
End If
Next Tbl
End Sub

Thanks, TAMATAM ; Business Intelligence & Analytics Professional

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your open Feedback only related to this Blog Posts. Please note that I cannot respond to the Anonymous Comments.

Subscribe to Blog Posts by Email

ExcelKingdom-Popular Posts