Administrator

Administrator

  • Tech Writer
  • 2.2k
  • 1.5m

Creating a Word Toolbar

Apr 8 2003 3:50 AM
Hello, I'm trying to create a Word add-in in forms of a toolbar in C#. I am using the example at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTipsTricksBuildingMicrosoftOfficeAdd-insWithVisualCNETVisualBasicNET.asp I get the error "Word.Application does not contain a definition for CommandBars". The onConnection mehthod calls the AddWordToolbar: wordApp = (Word.Application)application; Microsoft.Office.Core.CommandBar toolBar = null; toolBar = AddWordToolbar(wordApp, "RM toolbar."); And AddWordTollbar looks like this: private Microsoft.Office.Core.CommandBar AddWordToolbar( Word.Application word, string toolbarName) { Microsoft.Office.Core.CommandBar toolBar = null; try { // Create a command bar for the add-in object missing = System.Reflection.Missing.Value; toolBar = (Microsoft.Office.Core.CommandBar)word.CommandBars.Add(toolbarName, Microsoft.Office.Core.MsoBarPosition.msoBarTop, missing, true ); //<-This is where the error occurs, can't find CommandBars toolBar.Visible = true; return toolBar; } catch { return null; } } Does anyone have a clue on what can be the problem? regards George