Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2005, 04:08 PM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default remove Excel Toolbars using an ActiveX DLL

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


 
Old September 11th, 2005, 08:05 AM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

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.

Max





Similar Threads
Thread Thread Starter Forum Replies Last Post
Advantages /Disadvantages of ActiveX DLL & ActiveX priyank Beginning VB 6 6 February 19th, 2007 11:34 AM
ActiveX DLL Joann Beginning VB 6 6 January 25th, 2007 08:50 PM
Removing Excel toolbars from within ActiveX DLL maxpotters Excel VBA 1 September 11th, 2005 08:05 AM
How do I debug an ActiveX DLL referenced by Excel? James Diamond Pro VB 6 4 July 19th, 2004 01:05 PM
Referencing an ActiveX DLL from Excel james gold Excel VBA 1 September 10th, 2003 10:41 AM





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