Board index » delphi » How can I make a Word-menuBar ?

How can I make a Word-menuBar ?

Hi,
I use D5 and a WordApplication object on a form.
I want to create, in a document, a menu with sub/sub/submenu (like the
command bar "Insert")
I wrote :

myWord : TWordApplication;
cType : OLEvariant;
....

cType := msoControlPopUp;
with myWord.CommandBars.Item[1].Controls.Add(cType
,emptyParam,emptyParam,emptyParam,emptyParam) do begin
     Caption    := 'myMenu';
     name       := 'cb0';
 end;

this works but :
1.  It has an arrow mark at right (indicating that it has subItems but I
don't want it)
2. I can't add items in it. More of this I can't do each item to have
subitems etc
3. I want each item to have a caption

The VBA syntax for this can't help due to differences with Delphi syntax.
can somebody help me ?

thanks in advance

 

Re:How can I make a Word-menuBar ?


Where do you get the "msoControlPopUp" const/type? which unit?

regards jari

Quote
NAB wrote:
> Hi,
> I use D5 and a WordApplication object on a form.
> I want to create, in a document, a menu with sub/sub/submenu (like the
> command bar "Insert")
> I wrote :

> myWord : TWordApplication;
> cType : OLEvariant;
> ....

> cType := msoControlPopUp;
> with myWord.CommandBars.Item[1].Controls.Add(cType
> ,emptyParam,emptyParam,emptyParam,emptyParam) do begin
>      Caption    := 'myMenu';
>      name       := 'cb0';
>  end;

> this works but :
> 1.  It has an arrow mark at right (indicating that it has subItems but I
> don't want it)
> 2. I can't add items in it. More of this I can't do each item to have
> subitems etc
> 3. I want each item to have a caption

> The VBA syntax for this can't help due to differences with Delphi syntax.
> can somebody help me ?

> thanks in advance

Re:How can I make a Word-menuBar ?


Jari

Quote
> Where do you get the "msoControlPopUp" const/type? which unit?

on my machine it is in the unit Office2000

--
Chris Parkinson
Vertis Information Services

Re:How can I make a Word-menuBar ?


<<Nab:
I want to create, in a document, a menu with
sub/sub/submenu (like the command bar "Insert")

Quote

But the code you give adds a toolbar item, not a menu. To
add a menu you do something like this:

var
  SubMenu, Menu: CommandBarPopup;
  MenuItem: OleVariant;
begin
  { Create a temporary menu. Change the last parameter
    to False to make it permanent. }
  Menu := Word.CommandBars.ActiveMenuBar.Controls.Add(
    msoControlPopup, EmptyParam, EmptyParam, EmptyParam,  
  True) as CommandBarPopup;
  OleVariant(Menu).Caption := 'Forms';

  MenuItem := Menu.Controls.Add(msoControlButton,    
EmptyParam, EmptyParam, EmptyParam, True) as    
CommandBarButton;
  MenuItem.Caption := 'Medical';
  MenuItem.DescriptionText := 'Show a medical form';

  SubMenu := Menu.Controls.Add(msoControlPopup, EmptyParam,
     EmptyParam, EmptyParam, True) as CommandBarPopup;
  OleVariant(SubMenu).Caption := 'SubMenu';
  MenuItem := SubMenu.Controls.Add(msoControlButton,      
EmptyParam, EmptyParam, EmptyParam, True) as      
CommandBarButton;
  MenuItem.Caption := 'I''m in a submenu';

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:How can I make a Word-menuBar ?


I allready send a reply but Idn't see it so I repeat it.
The "msoControlPopUp" and simular stuf are in files office97.pas,
word97.pas, activeX.pas in the folder Delphi\ocx\servers.

Re:How can I make a Word-menuBar ?


I allready send a reply but Idn't see it so I repeat it.
The "msoControlPopUp" and simular stuf are in files office97.pas,
word97.pas, activeX.pas in the folder Delphi\ocx\servers.

Other Threads