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
'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
--------------------------------------------------------------------------------------------------------
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.