Print Page | Close Window

Changing Menu Captions

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=547
Printed Date: 19 April 2024 at 11:28am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Changing Menu Captions
Posted By: rdtcgriffin
Subject: Changing Menu Captions
Date Posted: 19 March 2004 at 3:01am

Hello!

I have the following code to create the menu:

    Set ControlView = CommandBars.ActiveMenuBar.Controls.Add(xtpControlPopup, 1, "File", -1, False)
    With ControlView.CommandBar.Controls
        Set Control = .Add(xtpControlButton, 2, "New", -1, False)
        .Add xtpControlButton, 3, "Open", -1, False
        .Add xtpControlButton, 4, "Close", -1, False
    End With

Then, later on I would lile to change the captions of the menu. For the main menu (File) I can change teh caption using:

    CommandBars.ActiveMenuBar.Controls.Item(1).Caption = "FileX"

But for it's submenus, I get "Invalid procedure call or argument" error message when I try this:
    CommandBars.ActiveMenuBar.Controls.Item(2).Caption = "OpenX"

What method should I use so that I can change the captions? Also, is the solution the same for toolbars?

Thanks in advance!

Rommel

 




Replies:
Posted By: SuperMario
Date Posted: 19 March 2004 at 6:30am
Just assign an Id to each control you will search for and use it in the FindControl method:

Set ControlFile =  CommandBars.ActiveMenuBar.FindControl(,ID_FILE_OPEN, ,True)
ControlFile.Caption = "Open File"


Posted By: rdtcgriffin
Date Posted: 21 March 2004 at 9:27pm

Thanks!

I can now change the captions of the buttons (xtpControlButton).

But how do I change the caption of type xtpControlPopup? I get "Run-time error 91 Object variable or With block not set" when I use the popup's ID for the code you gave above.



Posted By: Oleg
Date Posted: 22 March 2004 at 8:11am

For popup control you must additional assign its ID:

 Set ControlView = CommandBars.ActiveMenuBar.Controls.Add(xtpControlPopup, 10, "File", -1, False)

ControlView .Id = 10



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: rdtcgriffin
Date Posted: 22 March 2004 at 6:57pm
OK thanks. Got it wotking now



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net