p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Excel VBA (http://p2p.wrox.com/forumdisplay.php?f=79)
-   -   Removing toolbar from ActiveX DLL in VB6 (http://p2p.wrox.com/showthread.php?t=33234)

maxpotters September 8th, 2005 01:19 PM

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

maxpotters September 11th, 2005 08:04 AM


i found it myself. Set a reference in ActiveX DLL to "Microsoft Office Library 9.0", then type the following code:

If TB.Type = Office.msoBarTypeNormal
etc etc

The reference made sure that VB6 knows the constants used in VBA.


All times are GMT -4. The time now is 07:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.