Microsoft Office Tutorials and References
In Depth Information
Using Calendar Control for Office Applications
Option Explicit¶
' * * * * *¶
Public Sub CreateCommandBar()¶
'Variable declaration¶
Dim cmdBar As CommandBar¶
Dim cmdButton As CommandBarButton¶
Call RemoveCommandBar¶
Set cmdBar = Application.CommandBars.Add("Calendar", Temporary:=True)¶
Set cmdButton = cmdBar.Controls.Add(msoControlButton)¶
With cmdButton¶
'Caption to display on button¶
.Caption = "Calendar"¶
'Procedure name to run when button is clicked¶
.OnAction = "ShowForm"¶
'Style of new command bar button¶
.Style = msoButtonCaption¶
'Show new button¶
.Visible = True¶
End With¶
cmdBar.Visible = True¶
End Sub¶
' * * * * *¶
Public Sub RemoveCommandBar()¶
'Continue when error occurs¶
On Error Resume Next¶
'Remove custom control button¶
Application.CommandBars("Calendar").Delete¶
End Sub¶
' * * * * *¶
Private Sub Workbook_BeforeClose(Cancel As Boolean)¶
Call RemoveCommandBar¶
End Sub¶
' * * * * *¶
Private Sub Workbook_Open()¶
Call CreateCommandBar¶
End Sub¶
Cmb
If you are using Word, place the following code in the ThisDocument module.
Access this module by double-clicking the ThisDocument title in the Project
Explorer window (top left) or right-clicking the ThisDocument title and
selecting View Code from the drop-down menu.
Option Explicit¶
' * * * * *¶
Public Sub CreateCommandBar()¶
'Variable declaration¶
Dim cmdBar As CommandBar¶
Search JabSto ::




Custom Search