C# Snippets


Clipboard_Clear

Public Sub ClipboardClear()
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)

mClipboardObject = Nothing
End Sub

CmdBar_ButtonAdd

Public Function ButtonAdd(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonOnAction As String, _
ByVal sButtonCaption As String, _
Optional ByVal sButtonToolTip As String = "", _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As System.Int32 = 0, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal iButtonWidth As System.Int32 = 10, _
Optional ByVal bSelected As Boolean = False, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bShortcutMenu As Boolean = False, _
Optional ByVal bResetClipboard As Boolean = True) _
As Office.CommandBarButton

Dim objcommandbar As Office.CommandBar = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

ButtonAdd = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonAdd")
Exit Function
End If

If bShortcutMenu = False Then
objbutton = CType(mCommandBars.Item(sBarName).Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), Office.CommandBarButton)
Else
Dim iindex As System.Int32
For iindex = 1 To mCommandBars.Count

If mCommandBars.Item(iindex).Type = Office.MsoBarType.msoBarTypePopup And _
mCommandBars.Item(iindex).Name = sBarName Then

objbutton = CType(mCommandBars.Item(iindex).Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), Office.CommandBarButton)
Exit For
End If
Next iindex
End If

With objbutton
If (bPasteFace = False And iButtonFaceID = 0) Then
.Style = Office.MsoButtonStyle.msoButtonCaption
End If
If (bPasteFace = True Or iButtonFaceID > 0) Then
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
End If

.Tag = sButtonTag
.OnAction = sButtonOnAction
.Caption = sButtonCaption
.TooltipText = sButtonToolTip
.BeginGroup = bBeginGroup
.Width = iButtonWidth

If bPasteFace = False And iButtonFaceID > 0 Then .FaceId = iButtonFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If

If bSelected = True Then .State = Office.MsoButtonState.msoButtonDown
If bSelected = False Then .State = Office.MsoButtonState.msoButtonUp
End With
ButtonAdd = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonAdd", msCLASSNAME, _
"add the button with" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonAddFaceOnly

Public Function ButtonAddFaceOnly(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonOnAction As String, _
Optional ByVal sButtonToolTip As String = "", _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As System.Int32 = 0, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal iButtonWidth As System.Int32 = 20, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bResetClipboard As Boolean = True) _
As Office.CommandBarButton

Dim objbutton As Office.CommandBarButton = Nothing

ButtonAddFaceOnly = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonAddFaceOnly")
Exit Function
End If

objbutton = CType(mCommandBars.Item(sBarName).Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), Office.CommandBarButton)

With objbutton
.Style = Office.MsoButtonStyle.msoButtonIcon
.Tag = sButtonTag
.OnAction = sButtonOnAction
.TooltipText = sButtonToolTip
.BeginGroup = bBeginGroup
.Width = iButtonWidth

If bPasteFace = False And iButtonFaceID > 0 Then
.FaceId = iButtonFaceID
End If
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If
End With
ButtonAddFaceOnly = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonAddFaceOnly", msCLASSNAME, _
"add the 'face only' button with" & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonCaptionChange

Public Sub ButtonCaptionChange(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaptionExisting As String, _
ByVal sButtonCaptionNew As String)

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonCaptionChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
If (sButtonParameter.Length > 0) Then
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End If
If (sButtonCaptionExisting.Length > 0) Then
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaptionExisting Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End If
End With

If Not (objbutton Is Nothing) Then
objbutton.Caption = sButtonCaptionNew
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonCaptionChange", msCLASSNAME, _
"change the caption on the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"Caption: '" & sButtonCaptionExisting & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonCaptionGet

Public Function ButtonCaptionGet(ByVal sBarName As String, _
ByVal sButtonParameter As String) _
As String

Dim objbutton As Office.CommandBarButton = Nothing

ButtonCaptionGet = ""
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonCaptionGet")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With

If Not (objbutton Is Nothing) Then
ButtonCaptionGet = objbutton.Caption
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonCaptionGet", msCLASSNAME, _
"return the caption from the button with" & gsCRLF & _
"Parameter '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonDelete

Public Sub ButtonDelete(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
Optional ByVal sButtonCaption As String = "", _
Optional ByVal iButtonID As System.Int32 = -1)

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonDelete")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With

objbutton.Delete()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonDelete", msCLASSNAME, _
"delete the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"Tag: '" & sButtonTag & "'" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonEnabledChange

Public Sub ButtonEnabledChange(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonCaption As String, _
ByVal bEnable As Boolean, _
Optional ByVal iButtonID As System.Int32 = -1)

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonEnabledChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If iButtonID = -1 Then
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Else
If .Controls(iindex).Id = iButtonID Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If

End If
Next iindex
End With
objbutton.Enabled = bEnable

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonEnabledChange", msCLASSNAME, _
"enable or disable the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"Tag: '" & sButtonTag & "'" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonEnabledGet

Public Function ButtonEnabledGet(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
Optional ByVal sButtonCaption As String = "", _
Optional ByVal iButtonID As System.Int32 = -1) _
As Boolean

Dim objbutton As Office.CommandBarButton = Nothing

ButtonEnabledGet = False
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonEnabledGet")
Exit Function
End If

If sButtonCaption.Length = 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sButtonParameter.Length = 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaption Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

ButtonEnabledGet = objbutton.Enabled

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonEnabledGet", msCLASSNAME, _
"determine whether the button with" & gsCRLF & _
"Parameter '" & sButtonParameter & "'" & gsCRLF & _
"Tag '" & sButtonTag & "'" & gsCRLF & _
"Caption '" & sButtonCaption & "'" & gsCRLF & _
"is enabled or disabled" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonExists

Public Function ButtonExists(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
Optional ByVal sButtonCaption As String = "") _
As Boolean

Dim objbutton As Office.CommandBarButton = Nothing

ButtonExists = False
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonExists")
Exit Function
End If

If sButtonParameter.Length > 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sButtonCaption.Length > 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaption Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If objbutton Is Nothing Then ButtonExists = False
If Not (objbutton Is Nothing) Then ButtonExists = True

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonExists", msCLASSNAME, _
"determine if the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"Tag: '" & sButtonTag & "'" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"exists on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonFaceChange

Public Sub ButtonFaceChange(ByVal sBarName As String, _
ByVal iButtonID As System.Int32, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonCaption As String, _
ByVal iButtonFaceID As System.Int32, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal bResetClipboard As Boolean = True)

Dim objcommandbar As Office.CommandBar = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonFaceChange")
Exit Sub
End If

objcommandbar = mCommandBars.Item(sBarName)

If sButtonParameter.Length > 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If iButtonID > -1 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Id = iButtonID Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sButtonCaption.Length > 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaption Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

With objbutton
If bPasteFace = False And iButtonFaceID > 0 Then
.FaceId = iButtonFaceID
End If

If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonFaceChange", msCLASSNAME, _
"change the face of the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"Tag: '" & sButtonTag & "'" & gsCRLF & _
"ID: '" & iButtonID & "'" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"to a button with" & gsCRLF & _
"ID: " & iButtonFaceID & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonFaceCopyFromFile

Public Sub ButtonFaceCopyFromFile(ByVal sFolderPath As String, _
ByVal sFileName As String)

Try
If gbEND_GENERAL = True Then Exit Sub

Dim objdataobject As New System.Windows.Forms.DataObject()

mClipboardObject = System.Windows.Forms.Clipboard.GetDataObject()

objdataobject.SetData("Bitmap", System.Drawing.Image.FromFile(sFolderPath & sFileName))
System.Windows.Forms.Clipboard.SetDataObject(objdataobject)

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonFaceCopyFromFile", msCLASSNAME, _
"copy the Face ID from the file" & gsCRLF & _
"'" & sFolderPath & sFileName & "'" & gsCRLF & _
"and place it on the clipboard.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonFaceCopyFromImageList

Public Sub ButtonFaceCopyFromImageList(ByVal sImageListName As String, _
ByVal objImageList As System.Windows.Forms.ImageList, _
ByVal iImageIndexNo As System.Int32)

Try
If gbEND_GENERAL = True Then Exit Sub

Dim objdataobject As New System.Windows.Forms.DataObject()

mClipboardObject = System.Windows.Forms.Clipboard.GetDataObject()

objdataobject.SetData("Bitmap", objImageList.Images(iImageIndexNo))
System.Windows.Forms.Clipboard.SetDataObject(objdataobject)

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonFaceCopyFromImageList", msCLASSNAME, _
"copy image number '" & iImageIndexNo & "'" & gsCRLF & _
"from the imagelist '" & sImageListName & "'" & gsCRLF & _
"and place it on the clipboard.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonInsert

Public Function ButtonInsert(ByVal sBarName As String, _
ByVal iBeforeControlID As System.Int32, _
ByVal sBeforeControlParameter As String, _
ByVal sBeforeControlTag As String, _
ByVal sBeforeControlCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonOnAction As String, _
ByVal sButtonCaption As String, _
Optional ByVal sButtonToolTip As String = "", _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As System.Int32 = 0, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal iButtonWidth As System.Int32 = 10, _
Optional ByVal bSelected As Boolean = False, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bShortcutMenu As Boolean = False, _
Optional ByVal bResetClipboard As Boolean = True) _
As Office.CommandBarButton

Dim objcommandbar As Office.CommandBar = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

ButtonInsert = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonInsert")
Exit Function
End If

objcommandbar = mCommandBars.Item(sBarName)

With mCommandBars.Item(sBarName)
For ibeforecontrolno = 1 To .Controls.Count

If iBeforeControlID > 0 Then
If .Controls(ibeforecontrolno).Id = iBeforeControlID Then Exit For
End If

If sBeforeControlParameter.Length > 0 Then
If .Controls(ibeforecontrolno).Parameter = sBeforeControlParameter Then Exit For
End If

If sBeforeControlCaption.Length > 0 Then
If .Controls(ibeforecontrolno).Caption = sBeforeControlCaption Then Exit For
End If

Next ibeforecontrolno
End With

If bShortcutMenu = False Then
objbutton = CType(objcommandbar.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Before:=ibeforecontrolno, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), _
Office.CommandBarButton)
Else
Dim iindex As System.Int32
For iindex = 1 To mCommandBars.Count

If mCommandBars.Item(iindex).Type = Office.MsoBarType.msoBarTypePopup And _
mCommandBars.Item(iindex).Name = sBarName Then

objbutton = CType(objcommandbar.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Before:=ibeforecontrolno, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), _
Office.CommandBarButton)
Exit For
End If
Next iindex
End If

With objbutton
If (bPasteFace = False And iButtonFaceID = 0) Then
.Style = Office.MsoButtonStyle.msoButtonCaption
End If
If (bPasteFace = True Or iButtonFaceID > 0) Then
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
End If

.Tag = sButtonTag
.OnAction = sButtonOnAction
.Caption = sButtonCaption
.TooltipText = sButtonToolTip
.BeginGroup = bBeginGroup
.Width = iButtonWidth

If bPasteFace = False And iButtonFaceID > 0 Then .FaceId = iButtonFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If

If bSelected = True Then .State = Office.MsoButtonState.msoButtonDown
If bSelected = False Then .State = Office.MsoButtonState.msoButtonUp
End With
ButtonInsert = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonInsert", msCLASSNAME, _
"insert the button with" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonReturn

Public Function ButtonReturn(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
Optional ByVal sButtonCaption As String = "", _
Optional ByVal iButtonID As Int32 = -1) _
As Office.CommandBarButton

Dim objbutton As Office.CommandBarButton = Nothing

ButtonReturn = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonReturn")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
ButtonReturn = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonReturn", msCLASSNAME, _
"return the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonStateChange

Public Sub ButtonStateChange(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaption As String, _
ByVal bSelected As Boolean, _
Optional ByVal sButtonTag As String = "")

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonStateChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With

If bSelected = True Then objbutton.State = Office.MsoButtonState.msoButtonDown
If bSelected = False Then objbutton.State = Office.MsoButtonState.msoButtonUp

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonStateChange", msCLASSNAME, _
"change the state of the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ButtonStateGet

Public Function ButtonStateGet(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
Optional ByVal sButtonCaption As String = "", _
Optional ByVal sButtonTag As String = "") _
As Boolean

Dim objbutton As Office.CommandBarButton = Nothing

ButtonStateGet = False
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonStateGet")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With

If objbutton.State = Office.MsoButtonState.msoButtonDown Then ButtonStateGet = True
If objbutton.State = Office.MsoButtonState.msoButtonUp Then ButtonStateGet = False

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonStateGet", msCLASSNAME, _
"return the state of the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ButtonToolTipChange

Public Sub ButtonToolTipChange(ByVal sBarName As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaption As String, _
ByVal sButtonToolTip As String, _
Optional ByVal sButtonTag As String = "")

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ButtonToolTipChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
objbutton.TooltipText = sButtonToolTip

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonToolTipChange", msCLASSNAME, _
"change the tooltop text for the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_CheckBoxAdd

Public Function CheckBoxAdd(ByVal sBarName As String, _
ByVal sCheckboxParameter As String, _
ByVal sCheckboxTag As String, _
ByVal sCheckboxOnAction As String, _
ByVal sCheckboxCaption As String, _
Optional ByVal bSelected As Boolean = False, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iCheckboxFaceID As System.Int32 = 0, _
Optional ByVal bTemporary As Boolean = False) _
As Office.CommandBarButton

Dim objbutton As Office.CommandBarButton = Nothing

CheckBoxAdd = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("CheckBoxAdd")
Exit Function
End If

objbutton = CType(mCommandBars.Item(sBarName).Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sCheckboxParameter), _
Office.CommandBarButton)

With objbutton
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Tag = sCheckboxTag
.Caption = sCheckboxCaption
.OnAction = sCheckboxOnAction
.BeginGroup = bBeginGroup
If iCheckboxFaceID = 0 Then
If bSelected = True Then
.FaceId = giCHECKBOX_FACEID
.State = Office.MsoButtonState.msoButtonDown
End If
If bSelected = False Then
.FaceId = 1
.State = Office.MsoButtonState.msoButtonUp
End If
Else
.FaceId = iCheckboxFaceID
End If
End With
CheckBoxAdd = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("CheckBoxAdd", msCLASSNAME, _
"add the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckboxParameter & "'" & gsCRLF & _
"Caption: '" & sCheckboxCaption & "'" & gsCRLF & _
"Tag: '" & sCheckboxTag & "'" & gsCRLF & _
"to the command bar called '" & sBarName & ".", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_CheckBoxChange

Public Sub CheckBoxChange(ByVal sBarName As String, _
ByVal sCheckBoxParameter As String, _
ByVal sCheckBoxCaption As String, _
ByVal bSelected As Boolean, _
Optional ByVal sCheckBoxTag As String = "")

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If sCheckBoxParameter = "DontChange" Then
Exit Sub
End If

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("CheckBoxChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sCheckBoxParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With

If bSelected = True Then
objbutton.FaceId = giCHECKBOX_FACEID
objbutton.State = Office.MsoButtonState.msoButtonDown
End If
If bSelected = False Then
objbutton.FaceId = 1
objbutton.State = Office.MsoButtonState.msoButtonUp
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("CheckBoxChange", msCLASSNAME, _
"change the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_CheckBoxInsert

Public Function CheckBoxInsert(ByVal sBarName As String, _
ByVal sBeforeControlParameter As String, _
ByVal sBeforeControlTag As String, _
ByVal sBeforeControlCaption As String, _
ByVal sCheckboxParameter As String, _
ByVal sCheckboxTag As String, _
ByVal sCheckboxOnAction As String, _
ByVal sCheckboxCaption As String, _
Optional ByVal bSelected As Boolean = False, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iCheckboxFaceID As System.Int32 = 0, _
Optional ByVal bTemporary As Boolean = False) _
As Office.CommandBarButton

Dim objcommandbar As Office.CommandBar = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

CheckBoxInsert = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("CheckBoxInsert")
Exit Function
End If

objcommandbar = mCommandBars.Item(sBarName)

For ibeforecontrolno = 1 To objcommandbar.Controls.Count
If objcommandbar.Controls(ibeforecontrolno).Caption = sBeforeControlCaption Then
Exit For
End If
Next ibeforecontrolno

objbutton = CType(objcommandbar.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Before:=ibeforecontrolno, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sCheckboxParameter), _
Office.CommandBarButton)

With objbutton
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Tag = sCheckboxTag
.Caption = sCheckboxCaption
.OnAction = sCheckboxOnAction
.BeginGroup = bBeginGroup
If iCheckboxFaceID = 0 Then
If bSelected = True Then
.FaceId = giCHECKBOX_FACEID
.State = Office.MsoButtonState.msoButtonDown
End If
If bSelected = False Then
.FaceId = 1
.State = Office.MsoButtonState.msoButtonUp
End If
Else
.FaceId = iCheckboxFaceID
End If
End With
CheckBoxInsert = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("CheckBoxInsert", msCLASSNAME, _
"insert the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckboxParameter & "'" & gsCRLF & _
"Caption: '" & sCheckboxCaption & "'" & gsCRLF & _
"Tag: '" & sCheckboxTag & "'" & gsCRLF & _
"before the control with" & gsCRLF & _
"Caption: '" & sBeforeControlCaption & "'" & gsCRLF & _
"to the command bar called '" & sBarName & ".", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ComboBoxAdd

Public Function ComboBoxAdd(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sComboBoxTag As String, _
Optional ByVal sComboBoxToolTip As String = "", _
Optional ByVal iComboBoxWidth As System.Int32 = 50, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iComboBoxNoofDropLines As System.Int32 = 10, _
Optional ByVal bTemporary As Boolean = False) _
As Office.CommandBarComboBox

Dim objcombobox As Office.CommandBarComboBox = Nothing

ComboBoxAdd = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxAdd")
Exit Function
End If

objcombobox = CType(mCommandBars.Item(sBarName).Controls.Add( _
Type:=Office.MsoControlType.msoControlComboBox, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sComboBoxParameter), _
Office.CommandBarComboBox)
With objcombobox
.Tag = sComboBoxTag

'Not needed in COM Addins since we use the Tag
'.OnAction = sOnActionText
.Width = iComboBoxWidth
.TooltipText = sComboBoxToolTip
.BeginGroup = bBeginGroup
.DropDownLines = iComboBoxNoofDropLines
.ListIndex = 0
End With

ComboBoxAdd = objcombobox

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxAdd", msCLASSNAME, _
"add the combo box with" & gsCRLF & _
"Parameter '" & sComboBoxParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ComboBoxAddFiles

Public Sub ComboBoxAddFiles(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sFolderPath As String, _
ByVal sSearchPattern As String, _
Optional ByVal bSelectSingle As Boolean = True, _
Optional ByVal bDisplayCount As Boolean = False)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32
Dim asfilesarray() As String
Dim iarraycount As System.Int32
Dim snextfile As String

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxAddFiles")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
objcombobox.Clear()
End With

asfilesarray = System.IO.Directory.GetFiles(sFolderPath, sSearchPattern)

For iarraycount = 0 To asfilesarray.Length - 1
snextfile = CStr(asfilesarray(iarraycount))

snextfile = New System.IO.FileInfo(snextfile).Name

If (snextfile.Length > 0) Then objcombobox.AddItem(snextfile)
Next iarraycount

If iarraycount = 0 Then
'no files in the folder
objcombobox.AddItem("(none)")
objcombobox.ListIndex = 1
End If
If iarraycount = 1 And bSelectSingle = True Then
objcombobox.ListIndex = 1
End If
If iarraycount > 1 And bDisplayCount = True Then
objcombobox.AddItem("(" & objcombobox.ListCount & " files)", Index:=1)
objcombobox.ListIndex = 1
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxAddFiles", msCLASSNAME, _
"add all the files in the folder" & gsCRLF & _
"'" & sFolderPath & "'" & gsCRLF & _
"to the combo box with " & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxAddString

Public Sub ComboBoxAddString(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sComboBoxTextConCat As String, _
Optional ByVal sSeparateChar As String = ";", _
Optional ByVal bClearComboBox As Boolean = True)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32
Dim snextentry As String

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxAddString")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex

If bClearComboBox = True Then objcombobox.Clear()
End With

Do While (sComboBoxTextConCat.Length > 0)
If Microsoft.VisualBasic.InStr(1, sComboBoxTextConCat, sSeparateChar) = 0 Then
snextentry = sComboBoxTextConCat
sComboBoxTextConCat = ""
Else
snextentry = Microsoft.VisualBasic.Left(sComboBoxTextConCat, Microsoft.VisualBasic.InStr(1, sComboBoxTextConCat, sSeparateChar) - 1)
sComboBoxTextConCat = Microsoft.VisualBasic.Right(sComboBoxTextConCat, sComboBoxTextConCat.Length - snextentry.Length - 1)
End If
objcombobox.AddItem(Text:=snextentry)
Loop

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxAddString", msCLASSNAME, _
"add the string concatenation" & gsCRLF & _
"'" & sComboBoxTextConCat & "'" & gsCRLF & _
"to the combo box with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxAddTextFile

Public Sub ComboBoxAddTextFile(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sFolderPath As String, _
ByVal sFileName As String, _
ByVal sFileExtension As String)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxAddTextFile")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex

objcombobox.Clear()
End With

'Add code to get from textfile

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxAddTextFile", msCLASSNAME, _
"add all the lines from the text file" & gsCRLF & _
"'" & sFolderPath & sFileName & sFileExtension & "'" & gsCRLF & _
"to the combobox with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxClear

Public Sub ComboBoxClear(ByVal sBarName As String, _
ByVal sComboBoxParameter As String)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxClear")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With
objcombobox.Clear()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxClear", msCLASSNAME, _
"clear all the entries in the combobox with" & gsCRLF & _
"Parameter " & "'" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxDropDownLinesChange

Public Sub ComboBoxDropDownLinesChange(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal iNoofDropDownLines As System.Int32)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxDropDownLinesChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With
objcombobox.DropDownLines = iNoofDropDownLines

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxDropDownLinesChange", msCLASSNAME, _
"change the number of drop-down lines of the combobox with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxEnabledChange

Public Sub ComboBoxEnabledChange(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal bEnable As Boolean)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxEnabledChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With
objcombobox.Enabled = bEnable

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxEnabledChange", msCLASSNAME, _
"enable or disable the combobox with" & gsCRLF & _
"Parameter '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxItemInsert

Public Sub ComboBoxItemInsert(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sTextToAdd As String, _
ByVal iPositionToInsert As System.Int32)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxItemInsert")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With

objcombobox.AddItem(sTextToAdd, iPositionToInsert)

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxItemInsert", msCLASSNAME, _
"insert the item '" & sTextToAdd & "' " & gsCRLF & _
"into position '" & iPositionToInsert & "'" & gsCRLF & _
"of the combo box with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxItemRemove

Public Sub ComboBoxItemRemove(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sMatchItem As String)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxItemRemove")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With

For iindex = 1 To objcombobox.ListCount
If objcombobox.List(iindex) = sMatchItem Then
objcombobox.RemoveItem(iindex)
Exit For
End If
Next iindex

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxItemRemove", msCLASSNAME, _
"remove the item '" & sMatchItem & "'" & gsCRLF & _
"from the combo box with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxReturn

Public Function ComboBoxReturn(ByVal sBarName As String, _
ByVal sComboBoxParameter As String) _
As Office.CommandBarComboBox

Dim objcombobox As Office.CommandBarComboBox = Nothing

ComboBoxReturn = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxReturn")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With
ComboBoxReturn = objcombobox

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxReturn", msCLASSNAME, _
"return the combo box with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ComboBoxSelectionChange

Public Sub ComboBoxSelectionChange(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sMatchItem As String, _
Optional ByVal bInformUser As Boolean = True, _
Optional ByVal iComboBoxCtrlNo As System.Int32 = 0)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32
Dim bfoundmatch As Boolean

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxSelectionChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With

bfoundmatch = False
For iindex = 1 To objcombobox.ListCount
If objcombobox.List(iindex) = sMatchItem Then
bfoundmatch = True
objcombobox.ListIndex = iindex
Exit Sub
End If
Next iindex

If bfoundmatch = False Then
If bInformUser = True Then
Call System.Windows.Forms.MessageBox.Show( _
"The item '" & sMatchItem & "' is not in the combo box with" & _
" the parameter '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar '" & sBarName & "'.", _
gobjSolution.SolutionFormPrefix & "ComboboxSelectionChange [clsCmdBar]", _
Windows.Forms.MessageBoxButtons.OK, _
Windows.Forms.MessageBoxIcon.Exclamation)
End If
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxSelectionChange", msCLASSNAME, _
"change the selection in the combo box with" & gsCRLF & _
"Parameter: " & "'" & sComboBoxParameter & "'" & gsCRLF & _
"to the value '" & sMatchItem & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxSelectionExists

Public Function ComboBoxSelectionExists(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal sMatchItem As String) _
As Boolean

Dim objcombobox As Office.CommandBarComboBox = Nothing

ComboBoxSelectionExists = False
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxSelectionExists")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With

For iindex = 1 To objcombobox.ListCount
If objcombobox.List(iindex) = sMatchItem Then
ComboBoxSelectionExists = True
Exit Function
End If
Next iindex

ComboBoxSelectionExists = False

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxSelectionExists", msCLASSNAME, _
"determine if the text '" & sMatchItem & "'" & gsCRLF & _
"exists in the combo box " & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ComboBoxSelectionGet

Public Function ComboBoxSelectionGet(ByVal sBarName As String, _
ByVal sComboBoxParameter As String) _
As String

Dim objcombobox As Office.CommandBarComboBox = Nothing

ComboBoxSelectionGet = ""
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxSelectionGet")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With
ComboBoxSelectionGet = objcombobox.Text

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxSelectionGet", msCLASSNAME, _
"return the selection that has been made in the combo box with" & gsCRLF & _
"Parameter '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ComboBoxToComboBox

Public Sub ComboBoxToComboBox(ByVal sBarName As String, _
ByVal iComboBoxID As Int32, _
ByVal sComboBoxFromParameter As String, _
ByVal sComboBoxFromTag As String, _
ByVal cboComboBox As System.Windows.Forms.ComboBox)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxToComboBox")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxFromParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With

For iindex = 1 To objcombobox.ListCount
cboComboBox.Items.Add(objcombobox.List(iindex))
Next iindex

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxToComboBox", msCLASSNAME, _
"add all the items from the combo box with" & gsCRLF & _
"Parameter: '" & sComboBoxFromParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'." & gsCRLF & _
"and add them to the combobox '" & cboComboBox.Name & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxToListBox

Public Sub ComboBoxToListBox(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal lsbListBox As System.Windows.Forms.ListBox)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxToListBox")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With

For iindex = 1 To objcombobox.ListCount
lsbListBox.Items.Add(objcombobox.List(iindex))
Next iindex

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxToListBox", msCLASSNAME, _
"add all the items from the combo box with" & gsCRLF & _
"Parameter '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'." & gsCRLF & _
"and add them to the listbox '" & lsbListBox.Name & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ComboBoxWidthChange

Public Sub ComboBoxWidthChange(ByVal sBarName As String, _
ByVal sComboBoxParameter As String, _
ByVal iComboBoxWidth As System.Int32)

Dim objcombobox As Office.CommandBarComboBox = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxWidthChange")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sComboBoxParameter Then
objcombobox = CType(.Controls(iindex), Office.CommandBarComboBox)
Exit For
End If
Next iindex
End With
objcombobox.Width = iComboBoxWidth

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcombobox = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ComboBoxWidthChange", msCLASSNAME, _
"change the width of the combobox with" & gsCRLF & _
"Parameter: '" & sComboBoxParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlAddButton

Public Function ControlAddButton(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As Integer = 1, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal bEnable As Boolean = True, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bResetClipboard As Boolean = False) _
As Office.CommandBarButton

Dim objbutton As Office.CommandBarButton = Nothing

ControlAddButton = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlAdd")
Exit Function
End If

objbutton = CType(mCommandBars.Item(sBarName).Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID), _
Office.CommandBarButton)

With objbutton
.Caption = sControlCaption
.BeginGroup = bBeginGroup

If bPasteFace = False And iButtonFaceID > 0 Then .FaceId = iButtonFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If

.Enabled = bEnable
End With


Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlAddButton", msCLASSNAME, _
"add the control with" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ControlAddTest

Public Function ControlAddTest(ByVal objControlPopup As Office.CommandBarPopup, _
ByVal iControlID As System.Int32) _
As Boolean

Dim objcontrol As Office.CommandBarControl = Nothing

Try
If gbEND_GENERAL = True Then Exit Function

ControlAddTest = True
objcontrol = objControlPopup.Controls.Add(Id:=iControlID)

objcontrol.Delete()

Catch objCOMException As System.Runtime.InteropServices.COMException
ControlAddTest = False
Catch objException As Exception
ControlAddTest = False
Finally
objcontrol = Nothing

If ControlAddTest = False Then
Call clszMessagesGeneral.ToolbarBuiltInControlDoesNotExistWarning(iControlID, "")
End If
End Try

End Function

CmdBar_ControlEnabledChange

Public Sub ControlEnabledChange(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
ByVal bEnable As Boolean, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlEnabledChange")
Exit Sub
End If

If sControlCaption.Length > 0 Then
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sControlCaption Then
Exit For
End If
Next objcontrol
Else
objcontrol = mCommandBars.Item(sBarName).FindControl(Id:=iControlID)
End If

If (objcontrol Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.ToolbarControlDoesNotExistWarning(sBarName, _
iControlID, _
sControlCaption)
End If
Else
objcontrol.Enabled = bEnable
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlEnabledChange", msCLASSNAME, _
"enable or disable the control with" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlEnabledGet

Public Function ControlEnabledGet(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
Optional ByVal bInformUser As Boolean = True) _
As Boolean

Dim objcontrol As Office.CommandBarControl = Nothing

ControlEnabledGet = False
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlEnabledGet")
Exit Function
End If

If sControlCaption.Length > 0 Then
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sControlCaption Then
Exit For
End If
Next objcontrol
Else
objcontrol = mCommandBars.Item(sBarName).FindControl(Id:=iControlID)
End If

If (objcontrol Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.ToolbarControlDoesNotExistWarning(sBarName, _
iControlID, _
sControlCaption)
End If
Exit Function
End If

ControlEnabledGet = objcontrol.Enabled

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlEnabledGet", msCLASSNAME, _
"determine whether the control with" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"is enabled or disabled" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ControlExecute

Public Sub ControlExecute(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
Optional ByVal sControlCaption As String = "")

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlExecute")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Id = iControlID Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If

Next iindex
End With
objbutton.Execute()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlExecute", msCLASSNAME, _
"execute the control with" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlIDReturn

Public Function ControlIDReturn(ByVal sBarName As String, _
ByVal iControlPositionNo As System.Int32) _
As System.Int32

Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlIDReturn")
Exit Function
End If

ControlIDReturn = mCommandBars.Item(sBarName).Controls(iControlPositionNo).Id

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlIDReturn", msCLASSNAME, _
"return the ID for" & gsCRLF & _
"control number '" & iControlPositionNo & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ControlInsert

Public Sub ControlInsert(ByVal sBarName As String, _
ByVal iBeforeControlID As System.Int32, _
ByVal sBeforeControlCaption As String, _
ByVal sBeforeControlParameter As String, _
ByVal iControlID As System.Int32, _
Optional ByVal sControlCaption As String = "", _
Optional ByVal iButtonFaceID As System.Int32 = -1, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bTemporary As Boolean = False)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlInsert")
Exit Sub
End If

With mCommandBars.Item(sBarName)
For ibeforecontrolno = 1 To .Controls.Count

If iBeforeControlID > 0 Then
If .Controls(ibeforecontrolno).Id = iBeforeControlID Then Exit For
End If

If sBeforeControlCaption.Length > 0 Then
If .Controls(ibeforecontrolno).Caption = sBeforeControlCaption Then Exit For
End If

If sBeforeControlParameter.Length > 0 Then
If .Controls(ibeforecontrolno).Parameter = sBeforeControlParameter Then Exit For
End If

Next ibeforecontrolno
End With

objcontrol = mCommandBars.Item(sBarName).Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID, _
Before:=ibeforecontrolno)

objcontrol.BeginGroup = bBeginGroup

If iButtonFaceID > -1 Then
objbutton = CType(objcontrol, Office.CommandBarButton)
objbutton.FaceId = iButtonFaceID

If sControlCaption.Length > 0 Then objbutton.Caption = sControlCaption
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlInsert", msCLASSNAME, _
"insert the control with" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"before the control with" & gsCRLF & _
"ID: '" & iBeforeControlID & "'" & gsCRLF & _
"Caption: '" & sBeforeControlCaption & "'" & gsCRLF & _
"Parameter: '" & sBeforeControlParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlInsertButton

Public Sub ControlInsertButton(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
Optional ByVal iBeforeControlID As System.Int32 = 0, _
Optional ByVal sBeforeControlCaption As String = "", _
Optional ByVal iControlFaceID As System.Int32 = 0, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bResetClipboard As Boolean = True)

Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32
Dim ibeforecontrol As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlInsertButton")
Exit Sub
End If

If sBeforeControlCaption.Length > 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sBeforeControlCaption Then
ibeforecontrol = iindex
Exit For
End If
Next iindex
End With
End If

If iBeforeControlID > 0 Then
With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Id = iBeforeControlID Then
ibeforecontrol = iindex
Exit For
End If
Next iindex
End With
End If

If (sBeforeControlCaption.Length) > 0 Or (iBeforeControlID > 0) Then
objbutton = CType(mCommandBars.Item(sBarName).Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID, _
Before:=ibeforecontrol), Office.CommandBarButton)
Else
objbutton = CType(mCommandBars.Item(sBarName).Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID), Office.CommandBarButton)
End If


With objbutton
.BeginGroup = bBeginGroup

If bPasteFace = False And iControlFaceID > 0 Then .FaceId = iControlFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlInsertButton", msCLASSNAME, _
"insert the control with" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"before the control with" & gsCRLF & _
"ID: '" & iBeforeControlID & "'" & gsCRLF & _
"Caption: '" & sBeforeControlCaption & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlReturn

Public Function ControlReturn(ByVal sBarName As String, _
ByVal sControlTag As String, _
ByVal sControlParameter As String, _
Optional ByVal iControlID As System.Int32 = -1, _
Optional ByVal sControlCaption As String = "", _
Optional ByVal bInformUser As Boolean = False) _
As Office.CommandBarButton

Dim objbutton As Office.CommandBarButton = Nothing

ControlReturn = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call zCommandBarsIsNothing("ButtonReturn")
Exit Function
End If

objbutton = mCmdBarFind.FindButton(sBarName, _
sControlTag, _
sControlParameter, _
iControlID, _
sControlCaption, _
bInformUser)

ControlReturn = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As System.Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlReturn", msCLASSNAME, _
"return the button with" & gsCRLF & _
gsCRLF & _
"Tag: '" & sControlTag & "'" & gsCRLF & _
"Parameter: '" & sControlParameter & "'" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ControlsDelete

Public Sub ControlsDelete(ByVal sBarName As String)

Try
If gbEND_GENERAL = True Then Exit Sub

Dim icontrolcount As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ControlsDelete")
Exit Sub
End If

For icontrolcount = 1 To mCommandBars.Item(sBarName).Controls.Count
mCommandBars.Item(sBarName).Controls(1).Delete()
Next icontrolcount

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlsDelete", msCLASSNAME, _
"delete all the controls " & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlVisibleChange

Public Sub ControlVisibleChange(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
ByVal bVisible As Boolean, _
Optional ByVal bShortcutMenu As Boolean = False, _
Optional ByVal bInformUser As Boolean = False)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim icontrolno As System.Int32

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call zCommandBarsIsNothing("ButtonReturn")
Exit Sub
End If


If bShortcutMenu = False Then
objcontrol = mCmdBarFind.FindControl(sBarName, iControlID, sControlCaption)
objcontrol.Visible = bVisible
Exit Sub
Else
'cannot use FindControl as there are sometimes identical commands on the same shortcut menus
'"Insert Comment" on the Cell shortcut menu is an example

If (iControlID > -1) Then
For icontrolno = 1 To mCommandBars.Item(sBarName).Controls.Count
If mCommandBars.Item(sBarName).Controls(icontrolno).Id = iControlID Then
mCommandBars.Item(sBarName).Controls(icontrolno).Visible = bVisible
End If
Next icontrolno
End If

If sControlCaption.Length > 0 Then
End If
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As System.Exception
mobjException = objException

Finally
objcontrol = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlVisibleChange", msCLASSNAME, _
"display or hide the control with" & gsCRLF & _
gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ControlVisibleGet

Public Function ControlVisibleGet(ByVal sBarName As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
Optional ByVal bShortcutMenu As Boolean = False, _
Optional ByVal bInformUser As Boolean = False) _
As Boolean

Dim objcontrol As Office.CommandBarControl = Nothing
Dim icontrolno As Integer

ControlVisibleGet = False
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call zCommandBarsIsNothing("ControlVisibleGet")
Exit Function
End If

If bShortcutMenu = False Then
objcontrol = mCmdBarFind.FindControl(sBarName, iControlID, sControlCaption)
ControlVisibleGet = objcontrol.Visible
Exit Function

Else
'cannot use FindControl as there are sometimes identical commands on the same shortcut menus
'"Insert Comment" on the Cell shortcut menu is an example

If (iControlID > -1) Then
For icontrolno = 1 To mCommandBars.Item(sBarName).Controls.Count
If mCommandBars.Item(sBarName).Controls(icontrolno).Id = iControlID Then
If mCommandBars.Item(sBarName).Controls(icontrolno).Visible = True Then
ControlVisibleGet = True
Exit Function
End If
End If
Next icontrolno
End If

If sControlCaption.Length > 0 Then
End If
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As System.Exception
mobjException = objException

Finally
objcontrol = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ControlVisibleGet", msCLASSNAME, _
"determine whether the control with" & gsCRLF & _
gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"is visible or not" & gsCRLF & _
gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownAdd

Adds a drop-down menu to a command bar.
Public Function DropDownAdd(ByVal sBarName As String, _
ByVal objCommandBars As Office.CommandBars, _
Optional ByVal sDropDownTag As String = "", _
Optional ByVal sDropDownParameter As String = "", _
Optional ByVal iDropDownID As System.Int32 = -1, _
Optional ByVal sDropDownCaption As String = "", _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bInformUser As Boolean = True) _
As Office.CommandBarPopup

Dim objpopup As Office.CommandBarPopup

Try
If My.Settings.ERROR_OCCURRED = True Then Return Nothing : Exit Function

objpopup = CType(objCommandBars.Add(Office.MsoControlType.msoControlPopup, _
Temporary:=True), Office.CommandBarPopup)

objpopup.Parameter = sDropDownParameter
objpopup.Tag = sDropDownTag
objpopup.Caption = sDropDownCaption
objpopup.BeginGroup = bBeginGroup

Return objpopup

Return Nothing

Catch ex As Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex, _
"add this drop-down to the '" & sBarName & "' command bar:" & _
System.Environment.NewLine & _
System.Environment.NewLine & _
"Tag '" & sDropDownTag & "'" & System.Environment.NewLine & _
"Parameter '" & sDropDownParameter & "'" & System.Environment.NewLine & _
"ID '" & iDropDownID & "'" & System.Environment.NewLine & _
"Caption '" & sDropDownCaption & "'")
Return Nothing
End Try
End Function

CmdBar_DropDownButtonCaptionChange

Public Sub DropDownButtonCaptionChange(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaption As String, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonCaptionSet")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonCaptionChange", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

For iindex = 1 To objdropdownpopup.Controls.Count
If objdropdownpopup.Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex

objbutton.Caption = sButtonCaption

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonCaptionChange", msCLASSNAME, _
"change the caption to '" & sButtonCaption & "' for the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownButtonDelete

Public Sub DropDownButtonDelete(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sButtonParameter As String, _
Optional ByVal sButtonCaption As String = "", _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonEnabledChange")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonDelete", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

If sButtonCaption.Length = 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sButtonParameter.Length = 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaption Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

objbutton.Delete()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ButtonDelete", msCLASSNAME, _
"delete the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownButtonEnabledChange

Public Sub DropDownButtonEnabledChange(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaption As String, _
ByVal bEnable As Boolean, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonEnabledChange")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonEnabledChange", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

If sButtonCaption.Length = 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sButtonParameter.Length = 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaption Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

objbutton.Enabled = bEnable

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonEnabledChange", msCLASSNAME, _
"enable or disable the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Tag '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownButtonEnabledGet

Public Function DropDownButtonEnabledGet(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaption As String) _
As Boolean

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

DropDownButtonEnabledGet = False
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonEnabledGet")
Exit Function
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonEnabledGet", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
Exit Function
End If

With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
DropDownButtonEnabledGet = objbutton.Enabled

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonEnabledGet", msCLASSNAME, _
"determine if the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"is enabled or disabled" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownButtonFaceCopy

Public Sub DropDownButtonFaceCopy(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal iButtonID As System.Int32, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonFaceCopy")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonFaceCopy", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

For iindex = 1 To objdropdownpopup.Controls.Count
If objdropdownpopup.Controls(iindex).Id = iButtonID Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex

mClipboardObject = System.Windows.Forms.Clipboard.GetDataObject()
objbutton.CopyFace()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonFaceCopy", msCLASSNAME, _
"copy the face with" & gsCRLF & _
"ID: '" & iButtonID & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"from the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownButtonInsert

Public Function DropDownButtonInsert(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal iBeforeButtonID As System.Int32, _
ByVal sBeforeButtonCaption As String, _
ByVal sBeforeButtonParameter As String, _
ByVal sButtonCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonOnAction As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As System.Int32 = 1, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal sButtonState As String = "UP", _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bInformUser As Boolean = True, _
Optional ByVal bResetClipboard As Boolean = True) _
As Office.CommandBarButton

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

DropDownButtonInsert = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonInsert")
Exit Function
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName).FindControl(Tag:=sDropDownTag), _
Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonInsert", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Function
End If

With objdropdownpopup
For ibeforecontrolno = 1 To objdropdownpopup.Controls.Count

If iBeforeButtonID > 0 Then
If .Controls(ibeforecontrolno).Id = iBeforeButtonID Then Exit For
End If

If sBeforeButtonCaption.Length > 0 Then
If .Controls(ibeforecontrolno).Caption = sBeforeButtonCaption Then Exit For
End If

If sBeforeButtonParameter.Length > 0 Then
If .Controls(ibeforecontrolno).Parameter = sBeforeButtonParameter Then Exit For
End If

Next ibeforecontrolno
End With

objbutton = CType(objdropdownpopup.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Before:=ibeforecontrolno, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), Office.CommandBarButton)

With objbutton
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Tag = sButtonTag
.OnAction = sButtonOnAction
.Caption = sButtonCaption
.BeginGroup = bBeginGroup
If bPasteFace = False Then .FaceId = iButtonFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If
If sButtonState = "DOWN" Then
.State = Office.MsoButtonState.msoButtonDown
End If
End With
DropDownButtonInsert = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonInsert", msCLASSNAME, _
"insert the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownButtonReturn

Public Function DropDownButtonInsert(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal iBeforeButtonID As System.Int32, _
ByVal sBeforeButtonCaption As String, _
ByVal sBeforeButtonParameter As String, _
ByVal sButtonCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonOnAction As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As System.Int32 = 1, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal sButtonState As String = "UP", _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bInformUser As Boolean = True, _
Optional ByVal bResetClipboard As Boolean = True) _
As Office.CommandBarButton

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

DropDownButtonInsert = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonInsert")
Exit Function
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName).FindControl(Tag:=sDropDownTag), _
Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonInsert", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Function
End If

With objdropdownpopup
For ibeforecontrolno = 1 To objdropdownpopup.Controls.Count

If iBeforeButtonID > 0 Then
If .Controls(ibeforecontrolno).Id = iBeforeButtonID Then Exit For
End If

If sBeforeButtonCaption.Length > 0 Then
If .Controls(ibeforecontrolno).Caption = sBeforeButtonCaption Then Exit For
End If

If sBeforeButtonParameter.Length > 0 Then
If .Controls(ibeforecontrolno).Parameter = sBeforeButtonParameter Then Exit For
End If

Next ibeforecontrolno
End With

objbutton = CType(objdropdownpopup.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Before:=ibeforecontrolno, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Parameter:=sButtonParameter), Office.CommandBarButton)

With objbutton
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Tag = sButtonTag
.OnAction = sButtonOnAction
.Caption = sButtonCaption
.BeginGroup = bBeginGroup
If bPasteFace = False Then .FaceId = iButtonFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If
If sButtonState = "DOWN" Then
.State = Office.MsoButtonState.msoButtonDown
End If
End With
DropDownButtonInsert = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonInsert", msCLASSNAME, _
"insert the button with" & gsCRLF & _
"Parameter: '" & sButtonParameter & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownButtonUpDown

Public Sub DropDownButtonUpDown(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonCaption As String, _
ByVal bButtonUp As Boolean, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownButtonUpDown")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownButtonUpDown", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

If sButtonParameter.Length > 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Parameter = sButtonParameter Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sButtonCaption.Length > 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sButtonCaption Then
objbutton = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If


If bButtonUp = True Then
objbutton.State = Office.MsoButtonState.msoButtonUp
End If
If bButtonUp = False Then
objbutton.State = Office.MsoButtonState.msoButtonDown
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownButtonUpDown", msCLASSNAME, _
"change the button state to '" & bButtonUp & "' for the button with" & gsCRLF & _
"Caption: '" & sButtonCaption & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownCheckBoxCaptionChange

Public Sub DropDownCheckBoxCaptionChange(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sCheckBoxParameter As String, _
ByVal sCheckBoxCaption As String, _
ByVal iCheckBoxID As System.Int32, _
ByVal sNewCheckBoxParamater As String, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownCheckBoxCaptionChange")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownCheckBoxCaptionChange", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

For iindex = 1 To objdropdownpopup.Controls.Count
If sCheckBoxParameter.Length > 0 Then
If objdropdownpopup.Controls(iindex).Parameter = sCheckBoxParameter Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
Exit For
End If
End If

If sCheckBoxCaption.Length > 0 Then
If objdropdownpopup.Controls(iindex).Caption = sCheckBoxCaption Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
Exit For
End If
End If

If iCheckBoxID > -1 Then
If objdropdownpopup.Controls(iindex).Id = iCheckBoxID Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
Exit For
End If
End If
Next iindex

objbutton.Caption = sNewCheckBoxParamater

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownCheckBoxCaptionChange", msCLASSNAME, _
"change the caption of the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckBoxParameter & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"to the command bar called '" & sBarName & ".", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownCheckBoxCaptionGet

Public Function DropDownCheckBoxCaptionGet(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sCheckBoxParameter As String, _
ByVal iCheckBoxID As System.Int32, _
Optional ByVal bInformUser As Boolean = True) _
As String

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

DropDownCheckBoxCaptionGet = ""
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownCheckBoxCaptionGet")
Exit Function
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownCheckBoxCaptionGet", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Function
End If

For iindex = 1 To objdropdownpopup.Controls.Count
If objdropdownpopup.Controls(iindex).Parameter = sCheckBoxParameter Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex

DropDownCheckBoxCaptionGet = objbutton.Caption()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownCheckBoxCaptionGet", msCLASSNAME, _
"return the caption for the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckBoxParameter & "'" & gsCRLF & _
"ID: '" & iCheckBoxID & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"and tag '" & sDropDownTag & "'" & gsCRLF & _
"to the command bar called '" & sBarName & ".", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownCheckBoxEnabledChange

Public Sub DropDownCheckBoxEnabledChange(ByVal sBarName As System.String, _
ByVal sDropDownTag As System.String, _
ByVal sDropDownCaption As System.String, _
ByVal sCheckBoxParameter As System.String, _
ByVal sCheckBoxCaption As System.String, _
ByVal iCheckBoxID As System.Int32, _
ByVal bEnable As System.Boolean, _
Optional ByVal bInformUser As System.Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownCheckBoxEnabledChange")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownCheckBoxEnabledChange", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

With objdropdownpopup
For Each objcontrol In objdropdownpopup.Controls
If objcontrol.Parameter = sCheckBoxParameter Then
objbutton = CType(objcontrol, Office.CommandBarButton)
Exit For
End If
Next objcontrol
End With

objbutton.Enabled = bEnable

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownCheckBoxEnabledChange", msCLASSNAME, _
"enable or diable the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckBoxParameter & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownCheckBoxValue

Public Function DropDownCheckBoxValue(ByVal sBarName As System.String, _
ByVal sDropDownTag As System.String, _
ByVal sDropDownCaption As System.String, _
ByVal sCheckBoxParameter As System.String, _
Optional ByVal sCheckBoxCaption As System.String = "", _
Optional ByVal iCheckBoxID As System.Int32 = -1, _
Optional ByVal bInformUser As System.Boolean = True) _
As Boolean

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

DropDownCheckBoxValue = False
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownCheckBoxValue")
Exit Function
End If

If ToolbarExists(sBarName, , True) = False Then
DropDownCheckBoxValue = False
Exit Function
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownCheckBoxValue", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Function
End If

For iindex = 1 To objdropdownpopup.Controls.Count
If objdropdownpopup.Controls(iindex).Parameter = sCheckBoxParameter Then
objbutton = CType(objdropdownpopup.Controls(iindex), Office.CommandBarButton)
End If
Next iindex

If objbutton.State = Office.MsoButtonState.msoButtonUp Then
DropDownCheckBoxValue = False
End If
If objbutton.State = Office.MsoButtonState.msoButtonDown Then
DropDownCheckBoxValue = True
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownCheckBoxValue", msCLASSNAME, _
"return the status of the checkbox with" & gsCRLF & _
"Parameter: '" & sCheckBoxParameter & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownControlAdd

Public Sub DropDownControlAdd(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iControlFaceID As System.Int32 = 1, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal bEnable As Boolean = True, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bInformUser As Boolean = True, _
Optional ByVal bResetClipboard As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownControlAdd")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownControlAdd", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

objbutton = CType(objdropdownpopup.Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID), _
Office.CommandBarButton)

With objbutton
.Caption = sControlCaption
.BeginGroup = bBeginGroup

If bPasteFace = False And iControlFaceID > 0 Then .FaceId = iControlFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If

.Enabled = bEnable
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownControlAdd", msCLASSNAME, _
"add the control with" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"Face ID '" & iControlFaceID & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownControlDelete

Public Sub DropDownControlDelete(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
Optional ByVal sControlParameter As String = "", _
Optional ByVal sControlCaption As String = "", _
Optional ByVal iControlID As System.Int32 = -1, _
Optional ByVal sControlTag As String = "", _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objcontrol2 As Office.CommandBarControl = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownControlDelete")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
Exit For
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownControlDelete", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

If sControlParameter.Length > 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If objdropdownpopup.Controls(iindex).Parameter = sControlParameter Then
objcontrol2 = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If sControlCaption.Length > 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Caption = sControlCaption Then
objcontrol2 = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

'cant seem to use Find on a drop down ????
'objcontrol = objdropdownpopup.FindControl(id:=iControlId)
If iControlID > -1 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Id = iControlID Then
objcontrol2 = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

'cant seem to use Find on a drop down ????
'objcontrol = objdropdownpopup.FindControl(id:=iControlId)
If sControlTag.Length > 0 Then
With objdropdownpopup
For iindex = 1 To .Controls.Count
If .Controls(iindex).Tag = sControlTag Then
objcontrol2 = CType(.Controls(iindex), Office.CommandBarButton)
Exit For
End If
Next iindex
End With
End If

If Not objcontrol2 Is Nothing Then objcontrol2.Delete()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objdropdownpopup = Nothing
objcontrol = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownControlDelete", msCLASSNAME, _
"delete the control with " & gsCRLF & _
"Paramater: '" & sControlParameter & "'" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"ID: '" & iControlID & "'" & gsCRLF & _
"Tag: '" & sControlTag & "'" & gsCRLF & _
"on the drop-down menu with " & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownControlEnabledChange

Public Sub DropDownControlEnabledChange(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
ByVal bEnable As Boolean, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objcontrol2 As Office.CommandBarControl = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownControlEnabledChange")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownControlEnabledChange", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

'cant seem to use Find on a drop down ????
'objcontrol = objdropdownpopup.FindControl(id:=iControlId)
If iControlID > 0 Then
For Each objcontrol2 In objdropdownpopup.Controls
If objcontrol2.Id = iControlID Then
Exit For
End If
Next objcontrol2
End If

If sControlCaption.Length > 0 Then
For Each objcontrol2 In objdropdownpopup.Controls
If objcontrol2.Caption = sControlCaption Then
Exit For
End If
Next objcontrol2
End If

If (objcontrol2 Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.ToolbarControlDoesNotExistWarning(sBarName, _
iControlID, _
sControlCaption)
End If
Exit Sub
End If

If Not objcontrol2 Is Nothing Then objcontrol2.Enabled = bEnable

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownControlEnabledChange", msCLASSNAME, _
"enable or disable the control with" & gsCRLF & _
"ID: '" & iControlID & "' " & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownControlExecute

Public Sub DropDownControlExecute(ByVal sBarName As String, _
Optional ByVal iControlID As System.Int32 = -1, _
Optional ByVal sDropDownTag As String = "", _
Optional ByVal sDropDownCaption As String = "", _
Optional ByVal sControlCaption As String = "", _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objcontrol2 As Office.CommandBarControl = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim icontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownControlExecute")
Exit Sub
End If

If iControlID > -1 Then
objcontrol2 = mCommandBars.FindControl(Id:=iControlID)
objcontrol2.Execute()
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownControlExecute", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

For icontrolno = 1 To objdropdownpopup.Controls.Count
If objdropdownpopup.Controls(icontrolno).Caption = sControlCaption Then
objcontrol2 = CType(objdropdownpopup.Controls(icontrolno), Office.CommandBarControl)
Exit For
End If
Next icontrolno

If Not objcontrol2 Is Nothing Then objcontrol2.Execute()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then
If bInformUser = True Then
Call clsError.Handle("DropDownControlExecute", msCLASSNAME, _
"execute the button with" & gsCRLF & _
"Caption: '" & sControlCaption & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
" on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End If
End Try
End Sub

CmdBar_DropDownControlInsert

Public Sub DropDownControlInsert(ByVal sBarName As System.String, _
ByVal sDropDownTag As System.String, _
ByVal sDropDownCaption As System.String, _
ByVal iBeforeControlID As System.Int32, _
ByVal sBeforeControlCaption As System.String, _
ByVal sBeforeControlParameter As System.String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As System.String, _
Optional ByVal iControlFaceID As System.Int32 = 0, _
Optional ByVal bEnable As System.Boolean = True, _
Optional ByVal bBeginGroup As System.Boolean = False, _
Optional ByVal bInformUser As System.Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownControlInsert")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownControlInsert", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

With objdropdownpopup
For ibeforecontrolno = 1 To objdropdownpopup.Controls.Count

If iBeforeControlID > 0 Then
If .Controls(ibeforecontrolno).Id = iBeforeControlID Then Exit For
End If

If sBeforeControlCaption.Length > 0 Then
If .Controls(ibeforecontrolno).Caption = sBeforeControlCaption Then Exit For
End If

If sBeforeControlParameter.Length > 0 Then
If .Controls(ibeforecontrolno).Parameter = sBeforeControlParameter Then Exit For
End If

Next ibeforecontrolno
End With

If iControlID = -1 Then
objbutton = CType(objdropdownpopup.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Before:=ibeforecontrolno), Office.CommandBarButton)

Else
objbutton = CType(objdropdownpopup.Controls.Add( _
Id:=iControlID, _
Before:=ibeforecontrolno), Office.CommandBarButton)
End If

With objbutton
.Caption = sControlCaption
.BeginGroup = bBeginGroup
.Enabled = bEnable

If iControlFaceID > 0 Then .FaceId = iControlFaceID

.Enabled = bEnable
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownControlInsert", msCLASSNAME, _
"insert the control with" & gsCRLF & _
"Caption: " & "'" & sControlCaption & gsCRLF & _
"Face ID: '" & iControlFaceID & "'" & gsCRLF & _
"before the control with" & gsCRLF & _
"Caption: '" & sBeforeControlCaption & "'" & gsCRLF & _
"to the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownDelete

Public Sub DropDownDelete(ByVal sBarName As String, _
Optional ByVal sDropDownTag As String = "", _
Optional ByVal sDropDownCaption As String = "", _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownDelete")
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownDelete", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

objdropdownpopup.Delete()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownDelete", msCLASSNAME, _
"delete the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "' " & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"from the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownEnabled

Public Sub DropDownEnabled(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal bEnable As Boolean, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownEnabled")
Exit Sub
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownEnabled", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

objdropdownpopup.Enabled = bEnable

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("CmdBar_DropDownEnabled", msCLASSNAME, _
"enable or disable the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownExists

Public Function DropDownExists(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
Optional ByVal sDropDownCaption As String = "", _
Optional ByVal bInformUser As Boolean = False) _
As Boolean

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing

DropDownExists = False
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownExists")
Exit Function
End If

If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If objdropdownpopup Is Nothing Then DropDownExists = False
If Not objdropdownpopup Is Nothing Then DropDownExists = True

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownExists", msCLASSNAME, _
"determine if the drop-down menu with" & gsCRLF & _
"Caption: '" & sDropDownCaption & "'" & gsCRLF & _
"Tag '" & sDropDownTag & "'" & gsCRLF & _
"exists'" & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownExtendControlAdd

Public Sub DropDownExtendControlAdd(ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sExtensionTag As String, _
ByVal sExtensionCaption As String, _
ByVal iControlID As Integer, _
ByVal sControlCaption As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iControlFaceID As Integer = 1, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal bEnable As Boolean = True, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bInformUser As Boolean = True)

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objextendpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownExtendControlAdd")
Exit Sub
End If

If sExtensionTag.Length > 0 Then
objextendpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sExtensionTag, Recursive:=True), Office.CommandBarPopup)
Else
If sDropDownTag.Length > 0 Then
objdropdownpopup = CType(mCommandBars.Item(sBarName). _
FindControl(Tag:=sDropDownTag), Office.CommandBarPopup)
Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sDropDownCaption Then
objdropdownpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objdropdownpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuDropDownDoesNotExistWarning("DropDownExtendControlAdd", _
sBarName, _
sDropDownTag, _
sDropDownCaption)
End If
Exit Sub
End If

For Each objcontrol In objdropdownpopup.Controls
If objcontrol.Caption = sExtensionCaption Then
objextendpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objextendpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.MenuExtensionDoesNotExistWarning("DropDownExtendControlAdd", _
sBarName, _
sDropDownTag, _
sDropDownCaption, _
sExtensionTag, _
sExtensionCaption)
End If
Exit Sub
End If

If ControlAddTest(objextendpopup, iControlID) = False Then Exit Sub

objbutton = CType(objextendpopup.Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID), _
Office.CommandBarButton)

With objbutton
.Caption = sControlCaption
.BeginGroup = bBeginGroup
If bPasteFace = False Then .FaceId = iControlFaceID
If bPasteFace = True Then .PasteFace()

.Enabled = bEnable
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objextendpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownExtendControlAdd", msCLASSNAME, _
"add the control with" & gsCRLF & _
"ID: " & "'" & iControlID & "'" & gsCRLF & _
"Caption: " & "'" & sControlCaption & "'" & gsCRLF & _
"Face ID: '" & iControlFaceID & "'" & gsCRLF & _
"to the extension bar with" & gsCRLF & _
"Tag: '" & sExtensionTag & "'" & gsCRLF & _
"Caption: '" & sExtensionCaption & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"Caption '" & sDropDownCaption & "' " & gsCRLF & _
"on the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownExtendControlEnabledChange

Public Sub DropDownExtendControlEnabledChange(ByVal bEnable As Boolean, _
ByVal sBarName As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
ByVal sExtensionName As String, _
ByVal sControlName As String, _
Optional ByVal iDropDownCtrl As System.Int32 = -1, _
Optional ByVal iControlNo As System.Int32 = -1)

Try
If gbEND_GENERAL = True Then Exit Sub

'not written yet

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownExtendControlEnabledChange", msCLASSNAME, _
"enable or disable the control with" & gsCRLF & _
"Name: '" & sControlName & "'" & gsCRLF & _
"from the extension bar with" & gsCRLF & _
"Name: '" & sExtensionName & "'" & gsCRLF & _
"on the drop-down menu with" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_DropDownInsert

Public Function DropDownInsert(ByVal sBarName As String, _
ByVal sBeforeButtonCaption As String, _
ByVal sDropDownTag As String, _
ByVal sDropDownCaption As String, _
Optional ByVal iDropDownWidth As System.Int32 = 50, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bTemporary As Boolean = False) _
As Office.CommandBarPopup

Dim objcommandbar As Office.CommandBar = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing

DropDownInsert = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim ibeforecontrolno As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("DropDownInsert")
Exit Function
End If

objcommandbar = mCommandBars.Item(sBarName)

For ibeforecontrolno = 1 To objcommandbar.Controls.Count
If objcommandbar.Controls(ibeforecontrolno).Caption = sBeforeButtonCaption Then
Exit For
End If
Next ibeforecontrolno

Dim iindex As System.Int32
For iindex = 1 To mCommandBars.Count

If mCommandBars.Item(iindex).Type = Office.MsoBarType.msoBarTypePopup And _
mCommandBars.Item(iindex).Name = sBarName Then

objdropdownpopup = CType(mCommandBars.Item(sBarName).Controls.Add( _
Type:=Office.MsoControlType.msoControlPopup, _
Before:=ibeforecontrolno, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary)), _
Office.CommandBarPopup)
Exit For
End If
Next iindex

With objdropdownpopup
.Tag = sDropDownTag
.Caption = sDropDownCaption
.Width = iDropDownWidth
.BeginGroup = bBeginGroup

End With

DropDownInsert = objdropdownpopup

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownInsert", msCLASSNAME, _
"insert the drop-down menu with" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"Caption '" & sDropDownCaption & "'" & gsCRLF & _
"to the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_DropDownReturn

Public Function DropDownReturn(ByVal sBarName As String, _
ByVal sDropDownTag As String) _
As Office.CommandBarPopup

Dim objdropdownpopup As Office.CommandBarPopup = Nothing

DropDownReturn = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

Dim iindex As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ComboBoxReturn")
Exit Function
End If

With mCommandBars.Item(sBarName)
For iindex = 1 To .Controls.Count
If .Controls(iindex).Tag = sDropDownTag Then
objdropdownpopup = CType(.Controls(iindex), Office.CommandBarPopup)
Exit For
End If
Next iindex
End With

DropDownReturn = objdropdownpopup

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("DropDownReturn", msCLASSNAME, _
"return the drop-down menu with" & gsCRLF & _
"Tag: '" & sDropDownTag & "'" & gsCRLF & _
"from the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ExtendAdd

Public Sub ExtendAdd(ByVal sBarName As String, _
ByVal sExtensionCaption As String, _
ByVal sExtensionTag As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bInformUser As Boolean = True)

Dim objextendpopup As Office.CommandBarPopup = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ExtendAdd")
Exit Sub
End If

objextendpopup = CType(mCommandBars.Item(sBarName).Controls.Add( _
Type:=Office.MsoControlType.msoControlPopup, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary)), _
Office.CommandBarPopup)

With objextendpopup
.Tag = sExtensionTag
.Caption = sExtensionCaption
.BeginGroup = bBeginGroup
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objextendpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ExtendAdd", msCLASSNAME, _
"add the extension bar '" & sExtensionCaption & "'" & _
gsCRLF & "to the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ExtendButtonAdd

Public Function ExtendButtonAdd(ByVal sBarName As String, _
ByVal sExtensionTag As String, _
ByVal sExtensionCaption As String, _
ByVal sButtonCaption As String, _
ByVal sButtonParameter As String, _
ByVal sButtonTag As String, _
ByVal sButtonOnAction As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iButtonFaceID As System.Int32 = 0, _
Optional ByVal bPasteFace As Boolean = False, _
Optional ByVal sButtonState As String = "UP", _
Optional ByVal bTemporary As Boolean = False, _
Optional ByVal bInformUser As Boolean = True, _
Optional ByVal bResetClipboard As Boolean = True) _
As Office.CommandBarButton

Dim objcontrol As Office.CommandBarControl = Nothing
Dim objdropdownpopup As Office.CommandBarPopup = Nothing
Dim objextendpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

ExtendButtonAdd = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ExtendButtonAdd")
Exit Function
End If


If sExtensionTag.Length > 0 Then
objextendpopup = CType(mCommandBars.Item(sBarName).FindControl(Tag:=sExtensionTag), _
Office.CommandBarPopup)

Else
For Each objcontrol In mCommandBars.Item(sBarName).Controls
If objcontrol.Caption = sExtensionCaption Then
objextendpopup = CType(objcontrol, Office.CommandBarPopup)
End If
Next objcontrol
End If

If (objextendpopup Is Nothing) Then
If (bInformUser = True) Then
Call clszMessagesGeneral.ToolbarExtensionDoesNotExistWarning("ExtendButtonAdd", _
sBarName, _
sExtensionCaption, _
sExtensionTag)
End If
Exit Function
End If

objbutton = CType(objextendpopup.Controls.Add( _
Type:=Office.MsoControlType.msoControlButton, _
Parameter:=sButtonParameter, _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary)), _
Office.CommandBarButton)

With objbutton
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Tag = sButtonTag
.Caption = sButtonCaption
.OnAction = sButtonOnAction
.BeginGroup = bBeginGroup
If bPasteFace = False Then .FaceId = iButtonFaceID
If bPasteFace = True Then
.PasteFace()
If bResetClipboard = True Then
System.Windows.Forms.Clipboard.SetDataObject(mClipboardObject, False)
mClipboardObject = Nothing
Else
System.Windows.Forms.Clipboard.SetDataObject( _
New System.Windows.Forms.DataObject(), False)
End If
End If
If sButtonState = "DOWN" Then
.State = Office.MsoButtonState.msoButtonDown
End If
End With
ExtendButtonAdd = objbutton

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcontrol = Nothing
objdropdownpopup = Nothing
objextendpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ExtendButtonAdd", msCLASSNAME, _
"add the button called '" & sButtonParameter & "'" & gsCRLF & _
"to the extension bar with caption '" & sExtensionCaption & "' " & _
"and tag '" & sExtensionTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ExtendControlAdd

Public Sub ExtendControlAdd(ByVal sBarName As String, _
ByVal sExtensionTag As String, _
ByVal sExtensionCaption As String, _
ByVal iControlID As System.Int32, _
ByVal sButtonCaption As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal iFaceIdNo As System.Int32 = 0, _
Optional ByVal sButtonToolTip As String = "", _
Optional ByVal bTemporary As Boolean = False)

Dim objcommandbar As Office.CommandBar = Nothing
Dim objextendpopup As Office.CommandBarPopup = Nothing
Dim objbutton As Office.CommandBarButton = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim iindex As System.Int32

objcommandbar = mCommandBars.Item(sBarName)

For iindex = 1 To objcommandbar.Controls.Count
If objcommandbar.Controls(iindex).Tag = sExtensionTag Then
objextendpopup = CType(objcommandbar.Controls(iindex), Office.CommandBarPopup)
Exit For
End If
Next iindex

objbutton = CType(objextendpopup.Controls.Add( _
Temporary:=clsOfficeCore.TriStateFromBool(bTemporary), _
Id:=iControlID), _
Microsoft.Office.Core.CommandBarButton)

With objbutton
If sButtonCaption.Length > 0 Then .Caption = sButtonCaption
If iFaceIdNo > -1 Then .FaceId = iFaceIdNo
.TooltipText = sButtonToolTip
.BeginGroup = bBeginGroup
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing
objextendpopup = Nothing
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ExtendControlAdd", msCLASSNAME, _
"add the control with " & _
"the ID '" & iControlID & "'" & gsCRLF & _
"on to the extension bar with " & _
"the tag '" & sExtensionTag & "'" & gsCRLF & _
"on the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ExtendDelete

Public Function ExtendDelete(ByVal sBarName As String, _
ByVal sExtendTag As String) _
As Office.CommandBarPopup

ExtendDelete = Nothing

Call Me.DropDownDelete(sBarName, sExtendTag, "")

End Function

CmdBar_ExtendInsert

Public Function ExtendInsert(ByVal sBarName As String, _
ByVal sBeforeButtonCaption As String, _
ByVal sExtensionCaption As String, _
ByVal sExtensionParameter As String, _
ByVal sExtensionTag As String, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bTemporary As Boolean = False) _
As Office.CommandBarPopup

ExtendInsert = Me.DropDownInsert(sBarName, sBeforeButtonCaption, _
sExtensionTag, sExtensionCaption, , , bTemporary)

End Function

CmdBar_ExtendReturn

Public Function ExtendReturn(ByVal sBarName As String, _
ByVal sExtendTag As String) _
As Office.CommandBarPopup

ExtendReturn = Me.DropDownReturn(sBarName, sExtendTag)

End Function

CmdBar_FindDropDown

Public Function FindDropDown(ByVal sBarName As String, _
Optional ByVal sDropDownTag As String = "", _
Optional ByVal sDropDownParameter As String = "", _
Optional ByVal iDropDownID As Integer, _
Optional ByVal sDropDownCaption As String = "") As Office.CommandBarPopup

Dim objbar As Office.CommandBar
Dim icontrolno As Integer

Try

objbar = gApplicationWord.CommandBars.Item(sBarName)

If (sDropDownTag.Length > 0) Then
Return CType(gApplicationWord.CommandBars.FindControl(Type:=Office.MsoControlType.msoControlDropdown, _
Tag:=sDropDownTag), Office.CommandBarPopup)
End If

If (sDropDownParameter.Length > 0) Then
For icontrolno = 1 To gApplicationWord.CommandBars.Item(sBarName).Controls.Count
If gApplicationWord.CommandBars.Item(sBarName).Controls(icontrolno).Parameter = sDropDownParameter Then
Return CType(gApplicationWord.CommandBars.Item(sBarName).Controls(icontrolno), Office.CommandBarPopup)
Exit Function
End If
Next icontrolno
End If

If (iDropDownID > -1) Then
Return CType(gApplicationWord.CommandBars.FindControl(Type:=Office.MsoControlType.msoControlDropdown, _
Id:=iDropDownID), Office.CommandBarPopup)
End If

If Len(sDropDownCaption) > 0 Then
For icontrolno = 1 To gApplicationWord.CommandBars.Item(sBarName).Controls.Count
If gApplicationWord.CommandBars.Item(sBarName).Controls(icontrolno).Caption = sDropDownCaption Then
Return CType(gApplicationWord.CommandBars.Item(sBarName).Controls(icontrolno), Office.CommandBarPopup)
Exit Function
End If
Next icontrolno
End If

Return Nothing

Catch ex As System.Exception
Call modMessages.ErrorMessage(System.Reflection.MethodBase.GetCurrentMethod, ex.Message, _
"", False)
Return Nothing
End Try
End Function

CmdBar_FindExtendPopup

Public Function FindExtendPopup(ByVal objPopUp As Office.CommandBarPopup, _
ByVal sExtensionTag As String, _
ByVal sExtensionParameter As String, _
ByVal iExtensionID As System.Int32, _
ByVal sExtensionCaption As String, _
Optional ByVal bInformUser As Boolean = True) _
As Office.CommandBarPopup

Dim icontrolno As System.Int32

FindExtendPopup = Nothing

Try
If My.Settings.ERROR_OCCURRED = True Then Exit Function

If (sExtensionTag.Length > 0) Then
For icontrolno = 1 To objPopUp.Controls.Count
If objPopUp.Controls(icontrolno).Tag = sExtensionTag Then
FindExtendPopup = CType(objPopUp.Controls(icontrolno), Office.CommandBarPopup)
Exit For
End If
Next icontrolno
End If

If (sExtensionParameter.Length > 0) Then
For icontrolno = 1 To objPopUp.Controls.Count
If objPopUp.Controls(icontrolno).Parameter = sExtensionParameter Then
FindExtendPopup = CType(objPopUp.Controls(icontrolno), Office.CommandBarPopup)
Exit For
End If
Next icontrolno
End If

If (iExtensionID > -1) Then
For icontrolno = 1 To objPopUp.Controls.Count
If objPopUp.Controls(icontrolno).Id = iExtensionID Then
FindExtendPopup = CType(objPopUp.Controls(icontrolno), Office.CommandBarPopup)
Exit For
End If
Next icontrolno
End If

If (sExtensionCaption.Length > 0) Then
For icontrolno = 1 To objPopUp.Controls.Count
If objPopUp.Controls(icontrolno).Caption = sExtensionCaption Then
FindExtendPopup = CType(objPopUp.Controls(icontrolno), Office.CommandBarPopup)
Exit For
End If
Next icontrolno
End If

Catch ex As System.Exception
Call modMessages.ErrorMessage(System.Reflection.MethodBase.GetCurrentMethod, ex.Message, _
"", False)
End Try
End Function

CmdBar_FindPopUp

Public Function FindPopUp(ByVal sBarName As String, _
Optional ByVal sPopUpTag As String = "", _
Optional ByVal sPopUpParameter As String = "", _
Optional ByVal iPopUpID As System.Int32 = -1, _
Optional ByVal sPopUpCaption As String = "", _
Optional ByVal bInformUser As Boolean = True) _
As Office.CommandBarPopup

Dim objpopup As Office.CommandBarPopup = Nothing
Dim objbar As Office.CommandBar
Dim icontrolno As System.Int32

Try
If My.Settings.ERROR_OCCURRED = True Then Return Nothing : Exit Function

objbar = gApplicationWord.CommandBars.Item(sBarName)

If (sPopUpTag.Length > 0) Then
objpopup = CType(gApplicationWord.CommandBars.FindControl(Type:=Office.MsoControlType.msoControlPopup, _
Tag:=sPopUpTag), Office.CommandBarPopup)
End If

If (sPopUpParameter.Length > 0) Then
For icontrolno = 1 To objbar.Controls.Count
If objbar.Controls(icontrolno).Parameter = sPopUpParameter Then
objpopup = CType(objbar.Controls(icontrolno), Office.CommandBarPopup)
Exit For
End If
Next icontrolno
End If

If (iPopUpID > -1) Then
objpopup = CType(objbar.FindControl(Type:=Office.MsoControlType.msoControlPopup, _
Id:=iPopUpID), Office.CommandBarPopup)
End If

If (sPopUpCaption.Length > 0) Then
For icontrolno = 1 To objbar.Controls.Count
If objbar.Controls(icontrolno).Caption = sPopUpCaption Then
objpopup = CType(objbar.Controls(icontrolno), Office.CommandBarPopup)
Exit For
End If
Next icontrolno
End If

If (objpopup Is Nothing) And (bInformUser = True) Then
Call modMessages.CommandBar_ControlDoesNotExist(System.Reflection.MethodBase.GetCurrentMethod, _
sBarName, _
sPopUpTag, _
sPopUpParameter, _
iPopUpID, _
sPopUpCaption, _
False, _
True)
End If

Return objpopup

Catch ex As System.Exception
Call modMessages.ErrorMessage(System.Reflection.MethodBase.GetCurrentMethod, ex.Message, _
"", False)
Return Nothing
Finally
objbar = Nothing
End Try
End Function

CmdBar_FindPopupControl

Public Function FindPopupControl(ByVal objPopUp As Office.CommandBarPopup, _
ByVal sControlTag As String, _
ByVal sControlParameter As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
Optional ByVal bInformUser As Boolean = True) _
As Office.CommandBarControl

Dim icontrolno As System.Int32

FindPopupControl = Nothing
Try
If My.Settings.ERROR_OCCURRED = True Then Exit Function

If (sControlTag.Length > 0) Then
FindPopupControl = CType(objPopUp.Parent.FindControl(Tag:=sControlTag, _
Recursive:=True), Office.CommandBarControl)
End If

If (sControlParameter.Length > 0) Then
For icontrolno = 1 To objPopUp.Controls.Count
If objPopUp.Controls(icontrolno).Parameter = sControlParameter Then
FindPopupControl = CType(objPopUp.Controls(icontrolno), Office.CommandBarControl)
Exit For
End If
Next icontrolno
End If

If (iControlID > -1) Then
FindPopupControl = CType(objPopUp.Parent.FindControl(Id:=iControlID, _
Recursive:=True), Office.CommandBarControl)
End If

If (sControlCaption.Length > 0) Then
For icontrolno = 1 To objPopUp.Controls.Count
If objPopUp.Controls(icontrolno).Caption = sControlCaption Then
FindPopupControl = CType(objPopUp.Controls(icontrolno), Office.CommandBarControl)
Exit For
End If
Next icontrolno
End If

Catch ex As System.Exception
Call modMessages.ErrorMessage(System.Reflection.MethodBase.GetCurrentMethod, ex.Message, _
"", False)
End Try
End Function

CmdBar_LabelAdd

Public Sub LabelAdd(ByVal sBarName As String, _
ByVal sLabelName As String, _
Optional ByVal iLabelWidth As System.Int32 = 40, _
Optional ByVal bBeginGroup As Boolean = False, _
Optional ByVal bTemporary As Boolean = False)

Try
If gbEND_GENERAL = True Then Exit Sub


'With mCommandBars.Item(sBarName).Controls.Add(Type:=msoControlButton)
' ' .Style = Microsoft.Office.Core.msoButtonCaption
' .Tag = sLabelName
' .Caption = sLabelName
' .Width = iButtonWidth
' .BeginGroup = bBeginGroup
'End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("LabelAdd", msCLASSNAME, _
"add the label '" & sLabelName & "'" & _
" to the command bar called '" & sBarName & "'", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ToolbarCreate

Public Sub ToolbarCreate(ByVal sBarName As String, _
Optional ByVal bIsItVisible As Boolean = True, _
Optional ByVal objmsobarposition As Office.MsoBarPosition = Office.MsoBarPosition.msoBarFloating, _
Optional ByVal bTemporary As Boolean = False)

Dim objcommandbar As Office.CommandBar = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ToolbarCreate")
Exit Sub
End If

If ToolbarExists(sBarName) = False Then
objcommandbar = mCommandBars.Add( _
Name:=sBarName, _
Position:=objmsobarposition, _
MenuBar:=False, _
Temporary:=bTemporary)

objcommandbar.Visible = bIsItVisible
objcommandbar.Protection = Office.MsoBarProtection.msoBarNoCustomize Or _
Office.MsoBarProtection.msoBarNoResize
Else
Call clszMessagesGeneral.ToolbarAlreadyExistsInformation(sBarName)

Call ToolbarDelete(sBarName)
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ToolbarCreate", msCLASSNAME, _
"create the '" & objmsobarposition.ToString & "' command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ToolbarDelete

Public Sub ToolbarDelete(ByVal sBarName As String, _
Optional ByVal bJustControls As Boolean = False, _
Optional ByVal bInformUser As Boolean = True)

Dim objcommandbar As Office.CommandBar = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

objcommandbar = ToolbarGet(sBarName)
If objcommandbar Is Nothing Then
If (bInformUser = True) Then
Call clszMessagesGeneral.ToolbarHasAlreadyBeenDeletedInformation(sBarName)
End If

Else
If (bJustControls = False) Then
objcommandbar.Delete()
Else
Call ControlsDelete(sBarName)
End If
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ToolbarDelete", msCLASSNAME, _
"delete the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ToolbarExists

Public Function ToolbarExists(ByVal sBarName As String, _
Optional ByVal bInformUserExists As Boolean = False, _
Optional ByVal bInformUserDoesntExist As Boolean = False) _
As Boolean

Dim objcommandbar As Office.CommandBar = Nothing

ToolbarExists = False
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ToolbarExists")
Exit Function
End If

ToolbarExists = False
For Each objcommandbar In mCommandBars
If objcommandbar.Name = sBarName Then
ToolbarExists = True
If bInformUserExists = True Then
Call clszMessagesGeneral.ToolbarAlreadyExistsInformation(sBarName)
End If
Exit For
End If
Next

If (ToolbarExists = False) And (bInformUserDoesntExist = True) Then
Call clszMessagesGeneral.ToolbarDoesNotExistInformation(sBarName)
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ToolbarExists", msCLASSNAME, _
"determine if a command bar called '" & sBarName & "' currently exists.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_ToolbarGet

Public Function ToolbarGet(ByVal sBarName As String) _
As Office.CommandBar

Dim objcommandbar As Office.CommandBar = Nothing

ToolbarGet = Nothing
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ToolbarGet")
Exit Function
End If

objcommandbar = Nothing
For Each objcommandbar In mCommandBars
If objcommandbar.Name = sBarName Then
ToolbarGet = objcommandbar
Exit For
End If
Next

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objcommandbar = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

ToolbarGet = Nothing
Call clsError.Handle("ToolbarGet", msCLASSNAME, _
"return the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try

End Function

CmdBar_ToolbarReset

Public Sub ToolbarReset(ByVal sBarName As String, _
Optional ByVal bCheckToolbarExists As Boolean = False)

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ToolbarReset")
Exit Sub
End If

If bCheckToolbarExists = True Then
If ToolbarExists(sBarName, True) = False Then
Exit Sub
End If
End If
mCommandBars.Item(sBarName).Reset()

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ToolbarReset", msCLASSNAME, _
"reset the command bar '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ToolbarShow

Public Sub ToolbarShow(ByVal sBarName As String, _
ByVal bShowIt As Boolean)

Try
If gbEND_GENERAL = True Then Exit Sub

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ToolbarShow")
Exit Sub
End If

If (bShowIt = True And mCommandBars.Item(sBarName).Visible = False) Then
mCommandBars.Item(sBarName).Visible = True
ElseIf (bShowIt = False And mCommandBars.Item(sBarName).Visible = True) Then
mCommandBars.Item(sBarName).Visible = False
Else
End If

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ToolbarShow", msCLASSNAME, _
"display the command bar called '" & sBarName & "'.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_ToolbarVisible

Public Function ToolbarVisible(ByVal sBarName As String) _
As Boolean

ToolbarVisible = False
Try
If gbEND_GENERAL = True Then Exit Function

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("ToolbarVisible")
Exit Function
End If

ToolbarVisible = mCommandBars.Item(sBarName).Visible

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("ToolbarVisible", msCLASSNAME, _
"determine if the command bar called '" & sBarName & "' is visible.", _
mobjCOMException, mobjException)
End If
End Try
End Function

CmdBar_zExcelCOMAddinsButton

Public Sub zExcelCOMAddinsButton()

Dim objtoolsdropdownpopup As Office.CommandBarPopup = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim icontrol As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("zExcelCOMAddinsButton")
Exit Sub
End If

objtoolsdropdownpopup = CType(mCommandBars("Worksheet Menu Bar").Controls("Tools"), _
Office.CommandBarPopup)
With objtoolsdropdownpopup
For icontrol = 1 To .Controls.Count
If .Controls(icontrol).Id = 943 Then
If .Controls(icontrol + 1).Id <> 3754 Then
.Controls.Add(id:=3754, temporary:=False, before:=icontrol + 1)
'Call MsgBox("COM Addin button has been added")
Else
'Call MsgBox("COM Addin button has already been added")
End If
End If
Next
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objtoolsdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zExcelCOMAddinsButton", msCLASSNAME, _
"add the COM Addins button to the Tools drop-down menu.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_zMenuBarsReset

Public Sub zMenuBarsReset()

Dim cmdbar As Office.CommandBar

Try
If gbEND_GENERAL = True Then Exit Sub

For Each cmdbar In mCommandBars

Select Case cmdbar.Type
Case Office.MsoBarType.msoBarTypeMenuBar : cmdbar.Reset()
End Select
Next cmdbar

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zMenuBarsReset", msCLASSNAME, _
"reset all the toolbars.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_zPowerPointCOMAddinsButton

Public Sub zPowerPointCOMAddinsButton()

Dim objtoolsdropdownpopup As Office.CommandBarPopup = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim icontrol As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("zPowerPointCOMAddinsButton")
Exit Sub
End If

objtoolsdropdownpopup = CType(mCommandBars("Menu Bar").Controls("Tools"), _
Office.CommandBarPopup)
With objtoolsdropdownpopup
For icontrol = 1 To .Controls.Count
If .Controls(icontrol).Id = 943 Then
If .Controls(icontrol + 1).Id <> 3754 Then
.Controls.Add(Id:=3754, Temporary:=False, Before:=icontrol + 1)
'Call MsgBox("COM Addin button has been added")
Else
'Call MsgBox("COM Addin button has already been added")
End If
End If
Next
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objtoolsdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zPowerPointCOMAddinsButton", msCLASSNAME, _
"add the COM Addins button to the Tools drop-down menu.", _
mobjCOMException, mobjException)
End If
End Try

End Sub

CmdBar_zShortcutMenuAddIdentifier

Public Sub zShortcutMenuAddIdentifier(ByVal objCommandBar As Office.CommandBar)
Dim objbutton As Office.CommandBarButton

Try
If gbEND_GENERAL = True Then Exit Sub

objbutton = CType(objCommandBar.Controls.Add(Type:=Office.MsoControlType.msoControlButton, _
Temporary:=Office.MsoTriState.msoFalse, _
Before:=1), Office.CommandBarButton)

objbutton.FaceId = 59
objbutton.Caption = objCommandBar.Name & " - " & objCommandBar.Index

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objbutton = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zShortcutMenuAddIdentifier", msCLASSNAME, _
"identify and label all the shortcut menus.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_zShortcutMenusIdentify

Public Sub zShortcutMenusIdentify()

Dim cmdbar As Office.CommandBar

Try
If gbEND_GENERAL = True Then Exit Sub

For Each cmdbar In mCommandBars
If cmdbar.Name <> "System" And _
cmdbar.Type = Office.MsoBarType.msoBarTypePopup Then

Call Me.zShortcutMenuAddIdentifier(cmdbar)
End If
Next cmdbar

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
cmdbar = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zShortcutMenusIdentify", msCLASSNAME, _
"identify and label all the shortcut menus.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_zShortcutMenusReset

Public Sub zShortcutMenusReset()

Dim cmdbar As Office.CommandBar

Try
If gbEND_GENERAL = True Then Exit Sub

For Each cmdbar In mCommandBars

Select Case cmdbar.Type
Case Office.MsoBarType.msoBarTypePopup : cmdbar.Reset()
End Select
Next cmdbar

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zShortcutMenusReset", msCLASSNAME, _
"reset all the shortcut menus.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_zToolbarsReset

Public Sub zToolbarsReset()

Dim cmdbar As Office.CommandBar

Try
If gbEND_GENERAL = True Then Exit Sub

For Each cmdbar In mCommandBars

Select Case cmdbar.Type
Case Office.MsoBarType.msoBarTypeNormal : cmdbar.Reset()
End Select
Next cmdbar

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zToolbarsReset", msCLASSNAME, _
"reset all the toolbars.", _
mobjCOMException, mobjException)
End If
End Try
End Sub

CmdBar_zWordCOMAddinsButton

Public Sub zWordCOMAddinsButton()

Dim objtoolsdropdownpopup As Office.CommandBarPopup = Nothing

Try
If gbEND_GENERAL = True Then Exit Sub

Dim icontrol As System.Int32

If (mCommandBars Is Nothing) Then
Call CommandBarsIsNothing("zWordCOMAddinsButton")
Exit Sub
End If

objtoolsdropdownpopup = CType(mCommandBars("Menu Bar").Controls("Tools"), _
Office.CommandBarPopup)
With objtoolsdropdownpopup
For icontrol = 1 To .Controls.Count
If .Controls(icontrol).Id = 751 Then
If .Controls(icontrol + 1).Id <> 3754 Then
.Controls.Add(id:=3754, temporary:=False, before:=icontrol + 1)
'Call MsgBox("COM Addin button has been added")
Else
'Call MsgBox("COM Addin button has already been added")
End If
End If
Next
End With

Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException

Finally
objtoolsdropdownpopup = Nothing

If gbDEBUG_ERRMSG_GENERAL = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then

Call clsError.Handle("zWordCOMAddinsButton", msCLASSNAME, _
"add the COM Addins button to the Tools drop-down menu.", _
mobjCOMException, mobjException)
End If
End Try

End Sub

Message_CommandBar_DoesNotExist

Public Sub CommandBar_DoesNotExist(ByVal sBarName As String)

Dim smessage As String = ""

smessage = "The commandbar '" & sBarName & "' does not exist."

System.Windows.Forms.MessageBox.Show(smessage, _
My.Settings.APP_WINFORMS_TITLE, _
System.Windows.Forms.MessageBoxButtons.OK, _
System.Windows.Forms.MessageBoxIcon.Information)

smessage = smessage & " (" & System.Reflection.MethodBase.GetCurrentMethod.Name & ")"

Call Tracer_Add2("MESSAGE", smessage.Replace(System.Environment.NewLine, " ").Replace(" ", " "))
End Sub

Message_CommandBar_DropDownControlDoesNotExist

Public Sub CommandBar_DropDownControlDoesNotExist(ByVal objMethodBase As System.Reflection.MethodBase, _
ByVal objDropDownPopUp As Office.CommandBarPopup, _
ByVal sControlTag As String, _
ByVal sControlParameter As String, _
ByVal iControlID As System.Int32, _
ByVal sControlCaption As String, _
Optional ByVal bFlagError As Boolean = False, _
Optional ByVal bInformUser As Boolean = True)

Dim smessage As String = ""

Dim sSubroutineName As String
Dim sDeclaringType As String
Dim sClassName As String

sSubroutineName = objMethodBase.Name
sDeclaringType = objMethodBase.DeclaringType.ToString()
sClassName = sDeclaringType.Substring(sDeclaringType.IndexOf(".") + 1)

smessage = "This control does not exist on the '" & objDropDownPopUp.Caption & "' drop-down :" & _
System.Environment.NewLine & _
System.Environment.NewLine & _
"Tag: '" & sControlTag & "'" & System.Environment.NewLine & _
"Parameter: '" & sControlParameter & "'" & System.Environment.NewLine & _
"ID: '" & iControlID & "'" & System.Environment.NewLine & _
"Caption: '" & sControlCaption & "' "

Call modMessages.Exception_Warning(objMethodBase, smessage)
My.Settings.ERROR_OCCURRED = bFlagError

End Sub

Message_CommandBar_DropDownExtendControlDoesNotExist

Public Sub CommandBar_DropDownExtendControlDoesNotExist(ByVal objMethodBase As System.Reflection.MethodBase, _
ByVal objDropDownPopUp As Office.CommandBarPopup, _
ByVal sExtensionTag As String, _
ByVal sExtensionParameter As String, _
ByVal iExtensionID As System.Int32, _
ByVal sExtensionCaption As String, _
Optional ByVal bFlagError As Boolean = False, _
Optional ByVal bInformUser As Boolean = True)

Dim smessage As String = ""

Dim sSubroutineName As String
Dim sDeclaringType As String
Dim sClassName As String

sSubroutineName = objMethodBase.Name
sDeclaringType = objMethodBase.DeclaringType.ToString()
sClassName = sDeclaringType.Substring(sDeclaringType.IndexOf(".") + 1)

smessage = "This extension bar does not exist on the '" & objDropDownPopUp.Caption & "' drop-down :" & _
System.Environment.NewLine & _
System.Environment.NewLine & _
"Tag: '" & sExtensionTag & "'" & System.Environment.NewLine & _
"Parameter: '" & sExtensionParameter & "'" & System.Environment.NewLine & _
"ID: '" & iExtensionID & "'" & System.Environment.NewLine & _
"Caption: '" & sExtensionCaption & "' "

Call modMessages.Exception_Warning(objMethodBase, smessage)
My.Settings.ERROR_OCCURRED = bFlagError

End Sub

Message_CommandBar_HandlerNotInList

Public Sub CommandBar_HandlerNotInList(ByVal objMethodBase As System.Reflection.MethodBase, _
ByVal sParameter As String, _
ByVal sHandlerTag As String)

Dim smessage As String = ""

Dim sSubroutineName As String
Dim sDeclaringType As String
Dim sClassName As String

sSubroutineName = objMethodBase.Name
sDeclaringType = objMethodBase.DeclaringType.ToString()
sClassName = sDeclaringType.Substring(sDeclaringType.IndexOf(".") + 1)

smessage = "The parameter '" & sParameter & "' associated with this button has not been added to the Select/Case list." & _
System.Environment.NewLine & _
System.Environment.NewLine & _
"This needs to be added to the handler associated with all the buttons with the following tag: '" & sHandlerTag & "'."

System.Windows.Forms.MessageBox.Show(smessage, _
My.Settings.APP_WINFORMS_TITLE, _
System.Windows.Forms.MessageBoxButtons.OK, _
System.Windows.Forms.MessageBoxIcon.Information)

smessage = smessage & " (" & System.Reflection.MethodBase.GetCurrentMethod.Name & ")"

Call Tracer_Add2("MESSAGE", smessage.Replace(System.Environment.NewLine, " ").Replace(" ", " "))

End Sub

Message_CommandBar_ToolbarsRefreshed

Public Sub CommandBar_ToolbarsRefreshed()

Dim smessage As String = ""

smessage = "The following interface items have been refreshed:" & _
System.Environment.NewLine & _
System.Environment.NewLine & _
"Menu: 'File > New FICC Research Doc'" & System.Environment.NewLine & _
"Toolbar: '" & My.Settings.APP_TOOLBAR_MAIN_NAME & "'" & System.Environment.NewLine & _
"Toolbar: '" & My.Settings.APP_TOOLBAR_FORMATTING_NAME & "'" & System.Environment.NewLine & _
"Toolbar: '" & My.Settings.APP_TOOLBAR_REVIEWING_NAME & "'" & System.Environment.NewLine & _
"Toolbar: '" & My.Settings.APP_TOOLBAR_COMPILER_NAME & "'"

System.Windows.Forms.MessageBox.Show(smessage, _
My.Settings.APP_WINFORMS_TITLE & " - Refresh FICC Interface", _
System.Windows.Forms.MessageBoxButtons.OK, _
System.Windows.Forms.MessageBoxIcon.Information)

smessage = smessage & " (" & System.Reflection.MethodBase.GetCurrentMethod.Name & ")"

Call Tracer_Add2("MESSAGE", smessage.Replace(System.Environment.NewLine, " ").Replace(" ", " "))
End Sub

Message_CommandBarsReferenceIsNothing

Public Shared Sub Message_CommandBarsReferenceIsNothing(ByVal sProcedureName As String)

If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show(
"The reference to the object 'mCommandBars' " &
"in the procedure '" & sProcedureName & "' has been lost.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Exclamation)

'sets the flag to an error
clsError.ErrorFlagChange(True)
End Sub

Message_MenuExtensionDoesNotExist

Public Shared Sub Message_MenuExtensionDoesNotExist(ByVal sProcedureName As String,
ByVal sBarName As String,
Optional ByVal sPopUpTag As String = "",
Optional ByVal sPopUpParameter As String = "",
Optional ByVal iPopUpID As System.Int32 = -1,
Optional ByVal sPopUpCaption As String = "",
Optional ByVal sExtensionTag As String = "",
Optional ByVal sExtensionParameter As String = "",
Optional ByVal iExtensionID As System.Int32 = -1,
Optional ByVal sExtensionCaption As String = "",
Optional ByVal bFlagError As Boolean = False)

If clsError.ErrorFlag() = True Then Exit Sub

Dim smessage As String = ""

smessage = "The extension with" &
System.Environment.NewLine &
System.Environment.NewLine &
"Tag '" & sExtensionTag & "'" &
System.Environment.NewLine &
"Parameter '" & sExtensionParameter & "'" &
System.Environment.NewLine &
"ID '" & iExtensionID & "'" &
System.Environment.NewLine &
"Caption '" & sExtensionCaption & "'" &
System.Environment.NewLine &
System.Environment.NewLine &
"does not exist on the popup with" &
System.Environment.NewLine &
"Tag '" & sPopUpTag & "'" &
System.Environment.NewLine &
"Parameter '" & sPopUpParameter & "'" &
System.Environment.NewLine &
"ID '" & iPopUpID & "'" &
System.Environment.NewLine &
"Caption '" & sPopUpCaption & "'" &
System.Environment.NewLine &
System.Environment.NewLine &
"on the command bar called '" & sBarName & "'."

Call clsError.Exception(System.Reflection.MethodBase.GetCurrentMethod,
Nothing, Nothing, smessage, , False)

End Sub

Message_MenuPopUpDoesNotExist

Public Shared Sub Message_MenuPopUpDoesNotExist(ByVal sProcedureName As String,
ByVal sBarName As String,
Optional ByVal sPopUpTag As String = "",
Optional ByVal sPopUpParameter As String = "",
Optional ByVal iPopUpID As System.Int32 = -1,
Optional ByVal sPopUpCaption As String = "",
Optional ByVal bFlagError As Boolean = False)

If clsError.ErrorFlag() = True Then Exit Sub

Dim smessage As String = ""

smessage = "The popup menu with" &
System.Environment.NewLine &
System.Environment.NewLine &
"Tag '" & sPopUpTag & "'" &
System.Environment.NewLine &
"Parameter '" & sPopUpParameter & "'" &
System.Environment.NewLine &
"ID '" & iPopUpID & "'" &
System.Environment.NewLine &
"Caption '" & sPopUpCaption & "'" &
System.Environment.NewLine &
System.Environment.NewLine &
"does not exist on the command bar called '" & sBarName & "'."

Call clsError.Exception(System.Reflection.MethodBase.GetCurrentMethod,
Nothing, Nothing, smessage, , False)

End Sub

Message_ReferenceCommandBarsIsNothingExclamation

Public Shared Sub ReferenceCommandBarsIsNothingExclamation(ByVal sProcedureName As String)

If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show( _
"The reference to the object 'mCommandBars' " & _
"in the procedure '" & sProcedureName & "' has been lost.", _
gobjSolution.SolutionFormTitle, _
System.Windows.Forms.MessageBoxButtons.OK, _
System.Windows.Forms.MessageBoxIcon.Exclamation)

'sets the flag to an error
clsError.ErrorFlagChange(True)
End Sub

Message_RibbonDoesNotExist

Public Sub Message_RibbonDoesNotExist(ByVal sRibbonName As String)

Dim smessage As String = ""

smessage = "The ribbon was name '" & sRibbonName & "' does not exist."

System.Windows.Forms.MessageBox.Show(smessage, _
My.Settings.APP_WINFORMS_TITLE & " - " & "Ribbon Exists", _
System.Windows.Forms.MessageBoxButtons.OK, _
System.Windows.Forms.MessageBoxIcon.Information)

smessage = smessage & " (" & System.Reflection.MethodBase.GetCurrentMethod.Name & ")"

Call Tracer_Add2("MESSAGE", smessage.Replace(System.Environment.NewLine, " ").Replace(" ", " "))

End Sub

Message_ToolbarAlreadyExists

Public Shared Sub Message_ToolbarAlreadyExists(ByVal sBarName As String,
Optional ByVal bDeleteToolbar As Boolean = False,
Optional ByVal bFlagError As Boolean = False)

'If clsError.ErrorFlag() = True Then Exit Sub

If bDeleteToolbar = False Then
Call System.Windows.Forms.MessageBox.Show(
"The toolbar '" & sBarName & "' already exists.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information)
Else
Call System.Windows.Forms.MessageBox.Show(
"The toolbar '" & sBarName & "' already exists." &
System.Environment.NewLine &
"This will be deleted.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information)
End If

'sets the flag to an error
clsError.ErrorFlagChange(bFlagError)

End Sub

Message_ToolbarBuiltInControlDoesNotExist

Public Shared Sub Message_ToolbarBuiltInControlDoesNotExist(ByVal iControlID As System.Int32,
ByVal sControlCaption As String,
Optional ByVal bFlagError As Boolean = False)

If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show(
"The control with " &
"ID: '" & iControlID & "' and " &
"Caption: '" & sControlCaption & "' " &
System.Environment.NewLine &
"is not a recognised built-in command.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning)

'sets the flag to an error
clsError.ErrorFlagChange(bFlagError)
End Sub

Message_ToolbarButtonNoMacro

Public Shared Sub Message_ToolbarButtonNoMacro(Optional ByVal bFlagError As Boolean = False)

'If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show(
"This command has not been written yet." &
System.Environment.NewLine &
System.Environment.NewLine &
"What would you like this command to do ?",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Question)

'sets the flag to an error
clsError.ErrorFlagChange(bFlagError)
End Sub

Message_ToolbarControlDoesNotExist

Public Shared Sub Message_ToolbarControlDoesNotExist(ByVal sProcedureName As String,
ByVal sBarName As String,
ByVal sControlTag As String,
ByVal sControlParameter As String,
ByVal iControlID As System.Int32,
ByVal sControlCaption As String,
Optional ByVal bFlagError As Boolean = False)

If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show(
"The control with" &
System.Environment.NewLine &
System.Environment.NewLine &
"Tag: '" & sControlTag & "'" &
System.Environment.NewLine &
"Parameter: '" & sControlParameter & "'" &
System.Environment.NewLine &
"ID: '" & iControlID & "'" &
System.Environment.NewLine &
"Caption: '" & sControlCaption & "' " &
System.Environment.NewLine &
System.Environment.NewLine &
"does not exist on the command bar called '" & sBarName & "'.",
gobjSolution.SolutionFormPrefix & sProcedureName,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Warning)

'sets the flag to an error
clsError.ErrorFlagChange(bFlagError)
End Sub

Message_ToolbarDoesNotExist

Public Shared Sub Message_ToolbarDoesNotExist(ByVal sBarName As String,
Optional ByVal bFlagError As Boolean = False)

'If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show(
"The toolbar '" & sBarName & "' does not exist.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information)

'sets the flag to an error
clsError.ErrorFlagChange(bFlagError)

End Sub

Message_ToolbarExtensionDoesNotExist

Public Shared Sub Message_ToolbarExtensionDoesNotExist(ByVal sProcedureName As String,
ByVal sBarName As String,
Optional ByVal sExtensionCaption As String = "",
Optional ByVal sExtensionTag As String = "",
Optional ByVal bFlagError As Boolean = False)

If clsError.ErrorFlag() = True Then Exit Sub

Dim smessage As String = ""

If sExtensionCaption.Length = 0 Then
smessage = "The extension with the tag '" & sExtensionTag & "' does not exist " &
"on the command bar called '" & sBarName & "'."
End If

If sExtensionTag.Length = 0 Then
smessage = "The extension with the caption '" & sExtensionCaption & "' does not exist " &
"on the command bar called '" & sBarName & "'."
End If

Call clsError.Exception(System.Reflection.MethodBase.GetCurrentMethod,
Nothing, Nothing, smessage, , False)

End Sub

Message_ToolbarHasAlreadyBeenDeleted

Public Shared Sub Message_ToolbarHasAlreadyBeenDeleted(ByVal sBarName As String,
Optional ByVal bFlagError As Boolean = False)

'If clsError.ErrorFlag() = True Then Exit Sub

Call System.Windows.Forms.MessageBox.Show(
"The toolbar '" & sBarName & "' has already been deleted.",
gobjSolution.SolutionFormTitle,
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information)

'sets the flag to an error
clsError.ErrorFlagChange(bFlagError)
End Sub

OfficeRibbon_Return

Public Function OfficeRibbon_Return(ByVal sRibbonName As String, _
Optional ByVal bInformUser As Boolean = True) As Microsoft.Office.Tools.Ribbon.OfficeRibbon
Try
Call modGeneral.Tracer_AddSubroutineStart(System.Reflection.MethodBase.GetCurrentMethod)

Dim objRibbon As Microsoft.Office.Tools.Ribbon.OfficeRibbon
Dim icount As Integer

For icount = 1 To Globals.Ribbons.Count
objRibbon = Globals.Ribbons.Item(icount)

If (objRibbon.Name = sRibbonName) Then
Return objRibbon
End If
Next icount

If (bInformUser = True) Then
Call Message_General_RibbonDoesNotExist(sRibbonName)
End If

Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
End Try
End Function

Sep___Menu

public static string Sep___Menu(
int iIndent,
string sMenuName,
int SeparatorNo,
string sTitle,
string sGetTitle,
bool bVisible,
string sGetVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sTitle.Length > 0) { colArguments.Add("title"); }
if (sGetTitle.Length > 0) { colArguments.Add("getTitle"); }
if (bVisible == false) { colArguments.Add("visible"); }
if (sGetVisible.Length > 0) { colArguments.Add("getVisible"); }

sreturn += String.Empty.PadLeft(iIndent) + " sreturn += @" id=""" + sMenuName + "MenuSeparator" + SeparatorNo + @"""";
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(14, ref colArguments, "title", sTitle);
sreturn += clsRibbon.Tag_Attribute_String(14, ref colArguments, "getTitle", sGetTitle);
sreturn += clsRibbon.Tag_Attribute_Boolean(14, ref colArguments, "visible", bVisible);
sreturn += clsRibbon.Tag_Attribute_String(14, ref colArguments, "getVisible", sGetVisible);

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Sep__Bar

public static string Sep__Bar(
int iIndent,
string sToolbarName,
int iSeparatorNo,
bool bVisible)
{
string sreturn = "";

try
{
sreturn += String.Empty.PadLeft(iIndent) + " sreturn += @" id=""" + sToolbarName + @"ToolbarSaperator" + iSeparatorNo + @"""";

if (bVisible == false)
{
sreturn += String.Empty.PadLeft(iIndent + 10) + @"visible=""false""";
sreturn += System.Environment.NewLine;
}
sreturn += String.Empty.PadLeft(iIndent) + @"/>";
sreturn += System.Environment.NewLine;

return sreturn;

}
catch { return ""; }
finally { }
}

Tab_Select

Public Sub Tab_Select(ByVal sTabName As String)

Try
Call modGeneral.Tracer_AddSubroutineStart(System.Reflection.MethodBase.GetCurrentMethod)

Dim objTopWindow As Microsoft.Office.Core.IAccessible
objTopWindow = MSAAHelper.GetAccessibleObjectFromHandle(System.Diagnostics.Process.GetCurrentProcess.MainWindowHandle)

' Get the IAccessible object of the Ribbon property page.
Dim objAccessibleRibbon As Microsoft.Office.Core.IAccessible
objAccessibleRibbon = MSAAHelper.GetAccessibleObjectByNameAndRole(objTopWindow, New System.Text.RegularExpressions.Regex("Ribbon"), "property page", False)

' Find all visible ribbon tabs and show them in the list box.
Dim objAccessibleChildren As Microsoft.Office.Core.IAccessible()
objAccessibleChildren = MSAAHelper.GetAccessibleChildren(MSAAHelper.GetAccessibleObjectByNameAndRole(objAccessibleRibbon, New System.Text.RegularExpressions.Regex("Ribbon Tabs"), "page tab list", True))

For Each objAccessibleChild As Microsoft.Office.Core.IAccessible In objAccessibleChildren
If (objAccessibleChild.accChildCount > 0) Then

Dim objAccessibleTabs As Microsoft.Office.Core.IAccessible()
objAccessibleTabs = MSAAHelper.GetAccessibleChildren(objAccessibleChild)

For Each objAccessibleTab As Microsoft.Office.Core.IAccessible In objAccessibleTabs

Dim state As String = Ribbon_GetStateText(objAccessibleTab.accState(0))

If (objAccessibleTab.accName(0) = sTabName) Then
objAccessibleTab.accDoDefaultAction(0)
Exit Sub
End If

Next
End If
Next

Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
End Try
End Sub

Tag_Attribute_Boolean

private static string Tag_Attribute_Boolean(
int iIndent,
ref System.Collections.Generic.List colArguments,
string sStringTag,
bool bBooleanValue)
{
string sreturn = "";

try
{
if (bBooleanValue == false)
{
colArguments.Remove(sStringTag);
sreturn += String.Empty.PadLeft(iIndent) + sStringTag + @"=""" + bBooleanValue + @"""";
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }
}
return sreturn;
}
catch (System.Exception objException)
{
return "";
}
}

Tag_Attribute_String

private static string Tag_Attribute_String(
int iIndent,
ref System.Collections.Generic.List colArguments,
string sStringTag,
string sStringContents)
{
string sreturn = "";

try
{
if (sStringContents.Length > 0)
{
colArguments.Remove(sStringTag);
sreturn += String.Empty.PadLeft(iIndent) + sStringTag + @"=""" + sStringContents + @"""";
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }
}
return sreturn;
}
catch (System.Exception objException)
{
return "";
}
}

Tag_Box

public static string Tag_Box(
int iIndent,
string sID,
bool bVertical)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (bVertical == true) { colArguments.Add("vertical"); }

sreturn += String.Empty.PadLeft(iIndent) + " sreturn += @" id=""" + sID + @"""";

if (bVertical == false)
{
sreturn += System.Environment.NewLine;
sreturn += String.Empty.PadLeft(iIndent + 4) + @" boxstyle=""horizontal""";
}
else
{
colArguments.Remove("vertical");
sreturn += System.Environment.NewLine;
sreturn += String.Empty.PadLeft(iIndent + 4) + @" boxstyle=""vertical""";
}

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Button

public static string Tag_Button(
int iIndent,
string sIDMso,
string sLabel,
string sID,
string sImageMso,
string sImage,
string sSize,
string sGetEnabled,
string sScreentip,
bool bShowLabel,
bool bShowImage,
string sSupertip,
string sDescription,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sImageMso.Length > 0) { colArguments.Add("imageMso"); }
if (sImage.Length > 0) { colArguments.Add("image"); }
if (sSize.Length > 0) { colArguments.Add("size"); }
if (sGetEnabled.Length > 0) { colArguments.Add("getEnabled"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (bShowImage == false) { colArguments.Add("showImage"); }
if (sDescription.Length > 0) { colArguments.Add("description"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sIDMso.Length > 0)
{
colArguments.Remove("sIDMso");
sreturn += @" idMso=""" + sIDMso + @"""";
}
else
{
if (sID.Length == 0)
{
sreturn += String.Empty.PadLeft(iIndent + 7) + @" onAction=""Button_" + sLabel.Replace(" ", "") + @"""";
}
else
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""" + System.Environment.NewLine;
sreturn += String.Empty.PadLeft(iIndent + 7) + @" onAction=""Button_" + sID + @"""";
}
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "imageMso", sImageMso);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "image", sImage);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "size", sSize);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "getEnabled", sGetEnabled);

if (sLabel.Length > 0)
{
colArguments.Remove("label");
sreturn += String.Empty.PadLeft(iIndent + 7) + @"= label=""" + sLabel + @"""";

if (sLabel.Length > 7)
{
if (sLabel.Substring(0, 7) != "MISSING")
{
sreturn += System.Environment.NewLine;
sreturn += String.Empty.PadLeft(iIndent + 7) + @" enabled=""false""";
}
}

if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }
}

sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_Boolean(7, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_Boolean(7, ref colArguments, "showImage", bShowImage);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "description", sDescription);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(7, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_ButtonGroup

public static string Tag_ButtonGroup(
int iIndent,
string sID,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sID.Length > 0) { colArguments.Add("id"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "id", sID);
sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(7, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_CheckBox

public static string Tag_CheckBox(
int iIndent,
string sIDMso,
string sLabel,
string sID,
string sScreentip,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "


sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_ComboBox

public static string Tag_ComboBox(
int iIndent,
string sID,
string sSizeString,
string sScreentip,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sID.Length > 0) { colArguments.Add("id"); }
if (sSizeString.Length > 0) { colArguments.Add("sizeString"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sID.Length > 0)
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""" + System.Environment.NewLine;

sreturn += String.Empty.PadLeft(iIndent + 9) + @" onAction=""ComboBox_" + sID + @"""";
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "sizeString", sSizeString);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Control

public static string Tag_Control(
int iIndent,
string sIDMso,
string sLabel,
bool bShowLabel)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "idMso", sIDMso);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_CustomUI

private static string Tag_CustomUI(
string sVersion,
bool bInStudio,
bool bUseLoadImageCallback)
{
string sreturn = "";
string sschema = "";

try
{
if (bInStudio == true)
{
sreturn += @"" + System.Environment.NewLine;
}

if (sVersion == "2007") { sschema = @"http://schemas.microsoft.com/office/2006/01/customui"; }
if (sVersion == "2010") { sschema = @"http://schemas.microsoft.com/office/2009/07/customui"; }

sreturn += @"
if (bInStudio == true)
{
sreturn += System.Environment.NewLine + @" onLoad=""Ribbon_Load""";
}
if (bUseLoadImageCallback == true)
{
sreturn += System.Environment.NewLine + @" loadImage=""Callback_LoadImage""";
}
sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_DropDown

public static string Tag_DropDown(
int iIndent,
string sID,
string sSizeString,
string sScreentip,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sID.Length > 0) { colArguments.Add("id"); }
if (sSizeString.Length > 0) { colArguments.Add("sizeString"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sID.Length > 0)
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""" + System.Environment.NewLine;

sreturn += String.Empty.PadLeft(iIndent + 9) + @" onAction=""DropDown_" + sID + @"""";
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "sizeString", sSizeString);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_DynamicMenu

public static string Tag_DynamicMenu(
int iIndent,
string sIDMso,
string sLabel,
string sID,
string sImageMso,
string sImage,
string sGetContent,
bool bShowLabel,
bool bShowImage,
string sSize,
string sDescription,
string sScreentip,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sImageMso.Length > 0) { colArguments.Add("imageMso"); }
if (sImage.Length > 0) { colArguments.Add("image"); }
if (sGetContent.Length > 0) { colArguments.Add("getContent"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (bShowImage == false) { colArguments.Add("showImage"); }
if (sSize.Length > 0) { colArguments.Add("size"); }
if (sDescription.Length > 0) { colArguments.Add("description"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sIDMso.Length > 0)
{
colArguments.Remove("sIDMso");
sreturn += @" id=Mso""" + sIDMso + @"""";
}
else
{
if (sID.Length == 0)
{
sreturn += @" id=""" + sLabel.Replace(" ", "") + @"""";
}
else
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""";
}
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "imageMso", sImageMso);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "image", sImage);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "getContent", sGetContent);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showImage", bShowImage);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "size", sSize);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "description", sDescription);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_EditBox

public static string Tag_EditBox(
int iIndent,
string sID,
string sGetText,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sID.Length > 0) { colArguments.Add("id"); }
if (sGetText.Length > 0) { colArguments.Add("getText"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "getText", sGetText);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_End

private static string Tag_End(
int iIndent,
string sTag)
{
string sreturn = "";

try
{
if (sTag == "customUI")
{
sreturn += String.Empty.PadLeft(iIndent) + @"";
}
else
{
sreturn += String.Empty.PadLeft(iIndent) + @"";
sreturn += System.Environment.NewLine;
}

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Gallery

public static string Tag_Gallery(
int iIndent,
string sIDMso,
string sID,
string sLabel,
string sSize,
bool bShowLabel,
int iItemHeight,
int iItemWidth,
int iRows,
int iCols)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sSize.Length > 0) { colArguments.Add("size"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (iItemHeight > -1) { colArguments.Add("itemHeight"); }
if (iItemWidth > -1) { colArguments.Add("itemWidth"); }
if (iRows > -1) { colArguments.Add("rows"); }
if (iCols > -1) { colArguments.Add("columns"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "idMso", sIDMso);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "id", sID);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "size", sSize);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "itemHeight", iItemHeight.ToString());
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "itemWidth", iItemWidth.ToString());
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "rows", iRows.ToString());
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "columns", iCols.ToString());

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Group

private static string Tag_Group(
int iIndent,
string sID,
string sLabel,
string sGetVisible,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sGetVisible.Length > 0) { colArguments.Add("getVisible"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + " sreturn += @" id=""" + sID + @"""";
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += Tag_Attribute_String(iIndent + 7, ref colArguments, "label", sLabel);
sreturn += Tag_Attribute_String(iIndent + 7, ref colArguments, "getVisible", sGetVisible);
sreturn += Tag_Attribute_Boolean(iIndent + 7, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_ItemAdd

public static string Tag_ItemAdd(
int iIndent,
string sLabel,
string sID)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sID.Length > 0) { colArguments.Add("id"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sID.Length > 0)
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""";
}
else
{
sreturn += @" id=""" + sLabel.Replace(" ", "_") + @"""";
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(7, ref colArguments, "label", sLabel);

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_LabelControl

public static string Tag_LabelControl(
int iIndent,
string sID,
string sLabel,
bool bShowLabel,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sID.Length > 0) { colArguments.Add("id"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "id", sID);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @"/>";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Menu

public static string Tag_Menu(
int iIndent,
string sIDMso,
string sLabel,
string sID,
string sImageMso,
string sImage,
bool bShowLabel,
bool bShowImage,
string sSize,
string sGetEnabled,
string sDescription,
string sScreentip,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sImageMso.Length > 0) { colArguments.Add("imageMso"); }
if (sImage.Length > 0) { colArguments.Add("image"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (bShowImage == false) { colArguments.Add("showImage"); }
if (sSize.Length > 0) { colArguments.Add("size"); }
if (sGetEnabled.Length > 0) { colArguments.Add("getEnabled"); }
if (sDescription.Length > 0) { colArguments.Add("description"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "idMso", sIDMso);

if (sIDMso.Length ==0)
{
if (sID.Length == 0)
{
sreturn += @" id=""" + sLabel.Replace(" ", "") + @"""";
}
else
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""";
}
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "imageMso", sImageMso);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "image", sImage);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showImage", bShowImage);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "getEnabled", sGetEnabled);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "size", sSize);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "description", sDescription);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

if (sIDMso.Length > 0) { sreturn += @"/>"; }
if (sIDMso.Length == 0) { sreturn += @">"; }

sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Ribbon

private static string Tag_Ribbon(
int iIndent,
bool bStartFromScratch)
{
string sreturn = "";
string strueorfalse = "";

try
{
if (bStartFromScratch == true) { strueorfalse = "true"; }
if (bStartFromScratch == false) { strueorfalse = "false"; }

sreturn += String.Empty.PadLeft(iIndent) + @"";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Separator

public static string Tag_Separator(
int iIndent,
string sID,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sID.Length > 0) { colArguments.Add("id"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "id", sID);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_SplitButton

public static string Tag_SplitButton(
int iIndent,
string sIDMso,
string sLabel,
string sID,
string sImageMso,
string sImage,
string sSize,
string sGetEnabled,
string sScreentip,
bool bShowLabel,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sImageMso.Length > 0) { colArguments.Add("imageMso"); }
if (sImage.Length > 0) { colArguments.Add("image"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sSize.Length > 0) { colArguments.Add("size"); }
if (sGetEnabled.Length > 0) { colArguments.Add("getEnabled"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sIDMso.Length > 0)
{
colArguments.Remove("sIDMso");
sreturn += @" idMso=""" + sIDMso + @"""";
}
else
{
if (sID.Length > 0)
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""" + System.Environment.NewLine;
}
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "imageMso", sImageMso);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "image", sImage);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "size", sSize);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "getEnabled", sGetEnabled);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @">";

return sreturn;
}
catch (System.Exception objException)
{
return "";
}
finally
{
}
}

Tag_Tab

private static string Tag_Tab(
int iIndent,
string sID,
string sIDMso,
string sLabel,
string sInsertAfterMso,
string sInsertBeforeMso,
string sTag,
string sGetVisible,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sInsertAfterMso.Length > 0) { colArguments.Add("insertAfterMso"); }
if (sInsertBeforeMso.Length > 0) { colArguments.Add("insertBeforeMso"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (sGetVisible.Length > 0) { colArguments.Add("getVisible"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + " sreturn += @" id=""" + sID + @"""";
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += Tag_Attribute_String(iIndent + 4, ref colArguments, "idMso", sIDMso);
sreturn += Tag_Attribute_String(iIndent + 4, ref colArguments, "label", sLabel);
sreturn += Tag_Attribute_String(iIndent + 4, ref colArguments, "insertAfterMso", sInsertAfterMso);
sreturn += Tag_Attribute_String(iIndent + 4, ref colArguments, "insertBeforeMso", sInsertBeforeMso);
sreturn += Tag_Attribute_String(iIndent + 4, ref colArguments, "tag", sTag);
sreturn += Tag_Attribute_String(iIndent + 4, ref colArguments, "getVisible", sGetVisible);
sreturn += Tag_Attribute_Boolean(iIndent + 4, ref colArguments, "visible", bVisible);

sreturn += @">";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_Tabs

private static string Tag_Tabs(
int iIndent)
{
string sreturn = "";

try
{
sreturn += String.Empty.PadLeft(iIndent) + "";
sreturn += System.Environment.NewLine;

return sreturn;
}
catch { return ""; }
finally { }
}

Tag_ToggleButton

public static string Tag_ToggleButton(
int iIndent,
string sIDMso,
string sLabel,
string sID,
string sImageMso,
string sImage,
string sSize,
string sGetEnabled,
string sScreentip,
bool bShowLabel,
string sSupertip,
string sTag,
bool bVisible)
{
string sreturn = "";
System.Collections.Generic.List colArguments = new System.Collections.Generic.List();

try
{
if (sIDMso.Length > 0) { colArguments.Add("idMso"); }
if (sID.Length > 0) { colArguments.Add("id"); }
if (sImageMso.Length > 0) { colArguments.Add("imageMso"); }
if (sImage.Length > 0) { colArguments.Add("image"); }
if (sLabel.Length > 0) { colArguments.Add("label"); }
if (sSize.Length > 0) { colArguments.Add("size"); }
if (sGetEnabled.Length > 0) { colArguments.Add("getEnabled"); }
if (sScreentip.Length > 0) { colArguments.Add("screentip"); }
if (bShowLabel == false) { colArguments.Add("showLabel"); }
if (sSupertip.Length > 0) { colArguments.Add("supertip"); }
if (sTag.Length > 0) { colArguments.Add("tag"); }
if (bVisible == false) { colArguments.Add("visible"); }

sreturn += String.Empty.PadLeft(iIndent) + "
if (sIDMso.Length > 0)
{
colArguments.Remove("sIDMso");
sreturn += @" idMso=""" + sIDMso + @"""";
}
else
{
if (sID.Length > 0)
{
colArguments.Remove("sID");
sreturn += @" id=""" + sID + @"""" + System.Environment.NewLine;
sreturn += String.Empty.PadLeft(iIndent + 13) + @" onAction=""ToggleButton_" + sID + @"""";
}
}
if (colArguments.Count > 0) { sreturn += System.Environment.NewLine; }

sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "imageMso", sImageMso);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "image", sImage);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "label", sLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "size", sSize);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "getEnabled", sGetEnabled);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "screentip", sScreentip);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "showLabel", bShowLabel);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "supertip", sSupertip);
sreturn += clsRibbon.Tag_Attribute_String(13, ref colArguments, "tag", sTag);
sreturn += clsRibbon.Tag_Attribute_Boolean(13, ref colArguments, "visible", bVisible);

sreturn += @">";

return sreturn;
}
catch (System.Exception objException)
{
return "";
}
finally
{
}
}

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top