I am trying to write a code for exporting all the name of the tables and their columns from database into one excel sheet.
The code done till now is exporting all the tables with their complete information into excel sheets (each table generates one excel sheet but i don'want like this). Below is the code :
Private Sub Commande49_Click()
On Error GoTo Err_Commande49_Click
Dim strOut As String
Dim tbl As AccessObject
Dim f As Boolean
With Application.FileDialog(4) ' msoFileDialogFolderPicker
.Title = "Please select the target folder"
If .Show Then
strOut = .SelectedItems(1)
If Not Right(strOut, 1) = "\" Then
strOut = strOut & "\"
End If
Else
MsgBox "You didn't select a target folder.", vbExclamation
Exit Sub
End If
End With
f = (MsgBox("Do you want to export all tables to Excel (No = CSV)?", _
vbQuestion + vbYesNo) = vbYes)
For Each tbl In CurrentData.AllTables
If Not tbl.Name Like "MSys*" And Not tbl.Name Like "~" Then
If f Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, _
tbl.Name, strOut & tbl.Name & ".xlsx", True
Else
DoCmd.TransferText acExportDelim, , _
tbl.Name, strOut & tbl.Name & ".csv", True
End If
End If
Next tbl
Exit_Commande49_Click:
Exit Sub
Can anyone please help me with this issue.