Access.2007.VBA.Bibl..

(John Hannent) #1
FIGURE 16.22
The Ribbon.xml file added to the project’s resources file.

Each of the buttons in the Ribbon XML code needs its own procedure; the three button proce-
dures, plus a standard add-in error handler (same as in the VB 6 COM add-in) are listed next:

Public Sub CreateNewTable(ByVal control As _
Microsoft.Office.Core.IRibbonControl)

On Error GoTo ErrorHandler

Dim strSQL As String
Dim strTable As String
Dim obj As AccessObject

strTable = “tblTest”
strSQL = “CREATE TABLE “ & strTable & “ (FileDate DATE, “ _
& “FileNumber LONG, FileName TEXT (100), “ _
& “Current YESNO);”
Debug.Print(“SQL Statement: “ & strSQL)

Create table if it doesn’t already exist.

For Each obj In appAccess.CurrentData.AllTables
If obj.Name = strTable Then
‘Table already exists
GoTo ErrorHandlerExit
End If
Next

Part III Adding More Functionality to Office

Free download pdf