View Single Post
  #1 (permalink)  
Old September 8th, 2005, 01:19 PM
maxpotters maxpotters is offline
Authorized User
Join Date: Feb 2005
Location: , , Netherlands.
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
'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