Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 8th, 2005, 01:19 PM
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
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:04 AM
Authorized User
 
Join Date: Feb 2005
Location: , , Netherlands.
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
Removing Excel toolbars from within ActiveX DLL maxpotters Excel VBA 1 September 11th, 2005 08:05 AM
Creation of ActiveX DLL with VB6 james gold VB Components 2 December 28th, 2003 04:02 PM
Can a VB6 ActiveX DLL reference a spreadsheet? james gold Pro VB 6 0 October 2nd, 2003 10:02 AM
Creation of ActiveX DLL with VB6 james gold Pro VB 6 2 September 10th, 2003 08:19 AM





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