Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Changing Menu Captions
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Changing Menu Captions

 Post Reply Post Reply
Author
Message
rdtcgriffin View Drop Down
Newbie
Newbie


Joined: 18 March 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdtcgriffin Quote  Post ReplyReply Direct Link To This Post Topic: Changing Menu Captions
    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

 

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post 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"
Back to Top
rdtcgriffin View Drop Down
Newbie
Newbie


Joined: 18 March 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdtcgriffin Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
rdtcgriffin View Drop Down
Newbie
Newbie


Joined: 18 March 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdtcgriffin Quote  Post ReplyReply Direct Link To This Post Posted: 22 March 2004 at 6:57pm
OK thanks. Got it wotking now

Edited by rdtcgriffin
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.