Removing toolbar from ActiveX DLL in VB6
Hi all,
I'm trying to remove the Excel toolbars from within an ActiveX DLL made with VB6. I'm getting several errors, and I have problems with refering to a constant (msobarTypeNormal). If anyone has experience with this, your help will be much appreciated.
Here is my code:
Public Sub remove_toolbars(wkb) 'wkb is the refered workbook, this works correct!
'
Dim TB 'As what???
Dim TBNum As Integer
Dim xlWorkbook As Object
Dim xlSheet1 As Excel.Worksheet
'
Set xlWorkbook = GetObject(wkb)
Set xlSheet1 = xlWorkbook.Sheets(1)
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''
'clear the column
xlSheet1.Range("B:B").Clear
'Hide all visible toolbars and store their names
TBNum = 0
For Each TB In Excel.CommandBars 'here goes wrong
MsgBox "TB = " & TB
If TB.Type = msoBarTypeNormal Then 'does not recognize msoBarTypeNormal constant
MsgBox "Test"
If TB.Visible Then
TBNum = TBNum + 1
TB.Visible = False
xlSheet1.Cells(TBNum, 2).Value = TB.Name
End If
End If
Next TB
'
Excel.CommandBars("Worksheet Menu Bar").Enabled = False
MsgBox "done commandbars"
'
End Sub
Thanks in advance
Max
|