Pacific Database

Home | Contact | FAQs | View Cart

A world of information at your fingertips

Using the Access WizHook library

The WizHook library is a little-known library that you can use to do a variety of things in Access. It is completely unsupported by Microsoft, and the purpose of much of it is unknown (to all but Microsoft). Use it at your own risk!

Retrieving the names of all columns in a table or query:

Public Function GetColumnNames(strObjectName As String, _
	Optional ShowDetails As Boolean = False) As String
    'Returns the names of all columns in the specified table or query
    'If ShowDetails = False, the return value is like so:
    '       ID;Column1;Column2;
    'If ShowDetails = True, the return value is like so:
    '       ID;4;4;Column1;10;100;Column2;4;4;
    '  In this case,the columns represent the following data:
    '       Column name ; DAO datatype constant:
    '           (dbLong = 4, dbText = 10, etc) ; Max bytes per column
    
    With WizHook
        WizHook.Key = 51488399 'This is an internal Wizhook key.
			     'It only needs to be given once per
			     'user session, but most Wizhook
			     'functions won't work without it.
        If ShowDetails Then
            GetColumnNames = .GetInfoForColumns(strObjectName)
        Else
            GetColumnNames = .GetColumns(strObjectName)
        End If
    End With
End Function

Retrieving the name of the current VBA Project

Public Function GetVBAProject() As Object
    'Returns a VB Project object, without the need for a reference to
    'Visual Basic for Applications Extensibility library.
    With WizHook
        WizHook.Key = 51488399 'This is an internal Wizhook key.
			     'It only needs to be given once per
			     'user session, but most Wizhook
			     'functions won't work without it.
        Set GetVBAProject = .DbcVbProject
    End With
End Function