Results 1 to 2 of 2
  1. #1
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398

    Create Excel spreadsheet with Microsoft Access table info

    I'm trying to create a spreadsheet which lists all the tables within my DB. Within the table properties, their is a description. How do I find that within VBA code.


    Here's what I have so far:
    Dim lTbl As Long
    Dim lFld As Long
    Dim dBase As Database
    Dim xlApp As Object
    Dim wbExcel As Object
    Dim lRow As Long

    'Set current database to a variable and create a new Excel instance
    Set dBase = CurrentDb
    Set xlApp = CreateObject("Excel.Application")
    Set wbExcel = xlApp.workbooks.Add

    'Set on error in case there are no tables
    On Error Resume Next

    lRow = 1

    'Loop through all tables
    For lTbl = 0 To dBase.TableDefs.Count
    'If the table name is a temporary or system table then ignore it
    If Left(dBase.TableDefs(lTbl).Name, 1) = "~" Or _
    Left(dBase.TableDefs(lTbl).Name, 4) = "MSYS" Then


    '~ indicates a temporary table
    'MSYS indicates a system level table
    Else
    'Otherwise, loop through each table, writing the table and field names
    'to the Excel file
    lRow = lRow + 1
    With wbExcel.sheets(1)
    .Range("A" & lRow) = dBase.TableDefs(lTbl).Name
    End With
    End If
    Next lTbl
    'Resume error breaks
    On Error GoTo 0

    'Set Excel to visible and release it from memory
    xlApp.Visible = True
    Set xlApp = Nothing
    Set wbExcel = Nothing

    'Release database object from memory
    Set dBase = Nothing

  2. #2
    crowegreg is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Posts
    398
    I figured it out. Here's what I needed to add to my code:

    .Range("B" & lRow) = dBase.TableDefs(lTbl).Properties("Description").Va lue

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating excel spreadsheet from access vba
    By nyneave in forum Programming
    Replies: 1
    Last Post: 10-12-2012, 09:59 AM
  2. Replies: 1
    Last Post: 01-16-2012, 06:12 PM
  3. Replies: 4
    Last Post: 01-05-2012, 08:31 PM
  4. Email Excel Spreadsheet from Access
    By Nancy in forum Access
    Replies: 2
    Last Post: 11-09-2010, 02:37 PM
  5. Pivot Table from Excel Spreadsheet
    By Cgil32 in forum Access
    Replies: 0
    Last Post: 08-26-2010, 05:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums