Chapter 10
Is anyone having problems with adding the new CommandBar in Chapter 10 this is what I have and it comes back with "method or data not found" and the Style:
Option Compare Database
Option Explicit
Sub CreateCommandBar()
Dim cbReport As CommandBar
Dim btnButton As CommandButton
'delete the command Bar and if it does not exist, continue
On Error Resume Next
CommandBars("Wrox Report").Delete
On Error GoTo 0
'add the new command bar to the collection
Set cbReport = CommandBars.Add("Wrox Report", msoBarFloating)
'add Zoom Button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton, _
CommandBars("Print Preview") _
.Controls("Zoom").Id)
'add 2 pages Button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton, _
CommandBars("Print Preview") _
.Controls("Two Pages").Id)
'add Copy Button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton, _
CommandBars("database") _
.Controls("Copy").Id)
'add a customer button to the toolbar
Set btnButton = cbReport.Controls.Add(msoControlButton)
btnButton.Caption = "Test Button"
btnButton.Style = msoButtonCaption
'list the name of the procedure to call when the button is clicked
btnButton.OnClick = "DisplayMessage"
'display the new command bar by setting visible
cbReport.Visible = True
End Sub
Sub DisplayMessage()
MsgBox "The new button was clicked"
End Sub
Could someone help me!
|