Solved

Object Definitions Update for 2010

Posted on 2013-01-20
2
272 Views
Last Modified: 2013-01-20
In Access 2003, a friend helped me to identify objects in a database with the code below.  It no longer works for Office 2010.  Can someone please help me update this code so it's functional and outputs to Excel 2010?

Function tableflds() As String
Dim Dbs As Database
Dim xlapp As Object
Dim hdr As Object
Dim tbls  As RecordsetDefs
Dim fld As Fields
Dim tbl As Integer, r As Integer, c As Integer
Dim x As Object, t As Object
Set Dbs = CurrentDb
Set tbls = Application.CurrentDb.TableDefs
Set xlapp = CreateObject("excel.Application")
xlapp.workbooks.Add
Set hdr = xlapp.activeworkbook.worksheets(1).range("A:A")
xlapp.Visible = True
c = 0
tbl = -1
For Each t In tbls
tbl = tbl + 1
r = 2
c = c + 1
hdr.cells(1, c).value = t.Name
Set fld = tbls(tbl).PageFields 'MOD: Changed from .fieldsl

For Each x In fld
hdr.cells(r, c).value = x.Name
r = r + 1
Next x
Set fld = Nothing
Next t
End Function
0
Comment
Question by:CFMI
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 38798476
Try this code:
Public Function tableflds() As String
Dim xlapp As Object
Dim hdr As Object
Dim tbls  As Object
Dim fld As Object
Dim tbl As Integer, r As Integer, c As Integer
Dim x As Object, t As Object
On Error GoTo err1
tableflds = True
Set tbls = Application.CurrentDb.TableDefs
Set xlapp = CreateObject("excel.Application")
xlapp.workbooks.Add
Set hdr = xlapp.activeworkbook.worksheets(1).range("A:A")
xlapp.Visible = True
c = 0
tbl = -1
For Each t In tbls
tbl = tbl + 1
r = 2
c = c + 1
hdr.cells(1, c).Value = t.Name
Set fld = tbls(tbl).Fields 'MOD: Changed from .fieldsl

For Each x In fld
hdr.cells(r, c).Value = x.Name
r = r + 1
Next x
Set fld = Nothing
Next t
Exit Function
err1:
    tableflds = False
End Function

Open in new window

0
 
LVL 1

Author Closing Comment

by:CFMI
ID: 38798515
Perfect.  Thanks.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question