Saturday, April 18, 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 genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog