courses in microsoft access - listing macro contents vba
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » courses in microsoft access - Listing Macro Contents with VBA

courses in microsoft access - Listing Macro Contents with VBA

The UK's most regular instructor-led training courses.
Training information: courses in microsoft access · Courses in microsoft access · VBA training in London

· Low Priority · Version Standard

Listing Macro Contents with VBA

Michael has attended:
Access VBA course

by - delegate Michael [2 posts] (2007 Oct 3 Wed, 15:19) replyReply

I am currently trying to design a process that can tell me which macros a given query can be found in. Unlike with tables, you can't use object dependencies to do this and in some of our dbs, there are so many macros, it is a time consuming business to look through them all to see if your query is used.

What I would like to do is loop through each macro and create a table that lists macro and then the queries used.
eg:
Macro Name -------- Query Name
Macro 1 --------- Q1
Macro 1 ---------- Q2
Macro 2 --------- Q1
Macro 2 ---------- Q3

If I then wanted to know which macros Q1 was used in, I could easily see it was used in both Macro1 and Macro2.

I had hoped that this information was stored in one of the system tables as I have used these for a previous task, but I can't find it anywhere. My other thought was to use the "Convert to VBA" function inbuilt into access to create a VBA script that I could then adapt into a list but I can't work out how to do this either.

If anyone has any thoughts or ideas on how I could create a list like this I would be v.grateful.

Thanks,
Mike

Access VBA 2 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2003/XP 2008 Jul 10 Thu + 11 Fri Southwark 3 book now £475 £495
2003/XP 2008 Aug 7 Thu + 8 Fri Southwark 7 book now £345 £399
2003/XP 2008 Sep 4 Thu + 5 Fri Southwark 5 book now £450 £485
2003/XP 2008 Oct 20 Mon + 21 Tue Southwark 8 book now £275 £399
2003/XP 2008 Nov 6 Thu + 7 Fri Southwark 8 book now £275 £399
2003/XP 2008 Dec 4 Thu + 5 Fri Southwark 8 book now £275 £399
Full Schedule: See all 17 Access VBA course dates.
Bookings currently available until 5th November 2009.

RE: Listing Macro Contents with VBA

by - delegate Michael [2 posts] (2007 Oct 4 Thu, 09:37) replyReply

I have been able to find a function that claims to replicate the "Convert to VBA" Function and it is as follows:
DoCmd.SelectObject acMacro, strMacroName, True
DoCmd.RunCommand acCmdConvertMacrosToVisualBasic

However, it always seems to end up creating an empty module or give an error message. Having googled it I have found the below code that exports it to a txt fle that works but is a bit cumersome. Have you any ideas how I could replicate this so that it just populates an external module?

Public Function subConvertMacros2TextFile()

Dim db As Database
Dim cnt As Container
Dim doc As Document
Dim prp As Property
Dim mdl As Module
Dim intFileNum As Integer
Dim strMacroName As String
Dim strFileName As String
Dim strModuleName As String
Dim strModuleText As String

Set db = CurrentDb
Set cnt = db.Containers("scripts")

For Each doc In cnt.Documents
strMacroName = doc.Name
strFileName = "C:\" & strMacroName & ".TXT"
intFileNum = FreeFile
Open strFileName For Output As #intFileNum

' Print the accessible macro-properties in which we are not interested...
For Each prp In doc.Properties
Print #intFileNum, CStr(prp.Name) & vbTab & CStr(prp.Value)
Next prp

Print #intFileNum, vbCrLf & vbCrLf & "MODULE TEXT : " & vbCrLf & vbCrLf

DoCmd.SelectObject acMacro, strMacroName, True
' push keyboard commands into keyboard buffer
' these keystrokes are needed for two dialogboxes
' of the ConvertMacrosToVisualBasic wizzard
SendKeys "%e", False 'disable generating errorhandling
SendKeys "%c", False 'press Convert button
SendKeys "{ENTER}", False 'press OK button
DoCmd.RunCommand acCmdConvertMacrosToVisualBasic

' the wizzard adds "Converted Macro- " to the macroname
strModuleName = "Converted Macro- " & strMacroName
DoCmd.OpenModule strModuleName
Set mdl = Modules(strModuleName)
strModuleText = mdl.Lines(1, mdl.CountOfLines)
Print #intFileNum, strModuleText

DoCmd.Close acModule, strModuleName, acSaveNo
DoCmd.DeleteObject acModule, strModuleName
Close #intFileNum

Next doc

db.Close
End Function 'subConvertMacros2TextFile


Related articles

· Quick Microsoft Access Course: Creating an Inventory Control Database in 8 Simple Steps
· Quick MS Access Training: Creating Custom Database Tables in 12 Simple Steps
· 3 Reasons to Switch from Excel to MS Access - You'll be Glad You Did!
· Quick Access Database Courses: A 10 Step Lesson in Encrypting and Decrypting an Access Database
· Access Database Optimization: First Normal Form

Access tip:

Choosing data types in Access

Not sure which data type to use for your Access fields? Here are some guidelines to help you choose a data type to assign to a field.

- The Text data type can accept up to 255 characters. For information that will be recorded in paragraphs, use Memo.

- Also use Text for numbers that aren't going to be used in calculations, e.g. phone numbers.

- Use the Currency data type for monetary amounts.

- Use Date/Time for dates.

- Most other numbers can use the Number data type, but the Field Size property may have to be altered.

- For fields that have only two alternatives (yes, no) use Yes/No data type. If there is likely to be a third entry option (e.g. maybe or don't know) use Text instead.

View all Access hints and tips

Institute of IT Training - Accredited Training Provider Institute of IT Training - Accredited Training Provider Prodigy Platinum Learning Partner Microsoft Office Specialist Authorised Testing Centre

Microsoft Registered Partner
microsoft office
ms office project server

Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz