Board index » delphi » Replacing the "File Save"/"Save As" menu items

Replacing the "File Save"/"Save As" menu items

Is there a way to REPLACE the File Save/"Save As" menu items with my own
version that limits the folders "visible" for saving ?  (Word & Excel)

TIA
Ronaldo

 

Re:Replacing the "File Save"/"Save As" menu items


<<Ronaldo Souza:
Is there a way to REPLACE the File Save/"Save As" menu
items with my own version that limits the folders "visible"
for saving ?  (Word & Excel)

Quote

You can easily hide the menu/toolbar items:

var
  Temporary, Btn: OleVariant;
..
  { Hide the save menus }
  Temporary := True;
  Word.CommandBars['File'].Controls[
          'Save As...'].Delete(Temporary);
  Word.CommandBars['File'].Controls[
          'Save'].Delete(Temporary);
  Btn := Word.CommandBars['Standard'].Controls[3];
  Btn.Visible := False;

Adding your own replacements can be done in different ways,
depending on your Office version. If you're using Office
2000+, you'd probably want to use a COM addin, since you
could use the same addin in Word and Excel. However, if you
need compatibility with Office97, you'd have to add the
menuitems and assign VB macros to them. Of course the VB
macros can call Delphi functions if you like. Here's how to
add buttons and menuitems:

var
  MenuItem, ToolbarItem: OleVariant;
..
  MenuItem := Word.CommandBars['File'].Controls.Add(
                   msoControlButton, EmptyParam,
                   EmptyParam, EmptyParam, True);
  MenuItem.Caption := 'Save';
  MenuItem.DescriptionText := 'Save your work';
  MenuItem.Move(Word.CommandBars['File'], 3);

  ToolbarItem := Word.CommandBars['Standard'].Controls.Add(
                   msoControlButton, EmptyParam,
                   EmptyParam, EmptyParam, True);
  ToolbarItem.FaceId := 3;
  ToolbarItem.TooltipText := 'Save your work';

  { Note that a VB macro with the right name must
    exist before you assign it to the buttons! }
  MenuItem.OnAction := 'VBMacroName';
  ToolbarItem.OnAction := 'VBMacroName';

--
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:Replacing the "File Save"/"Save As" menu items


Deborah,
Thanks for your reply!
Ronaldo

Other Threads