ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> DevelopMentor-dotNET
DevelopMentor-dotNET
Re: [DOTNET] C# Office add-in woes
by Elton Wells other posts by this author
Nov 15 2001 9:14PM messages near this date
[DOTNET] C# Office add-in woes | Re: [DOTNET] Monitoring "last write" for a given file
Try specifying Missing.Value (from System.Reflection namespace) for the 2nd
through 5th parameters.  This shouldn't fail and I've found that it usually
gives me what I want.  If not, you can tweak the parameters from there.

Note that adding controls through the Controls collection is temporary and
the controls will not saved when VS is closed.  If you want the controls to
be saved you'll have to use AddCommandBar/AddNamedCommand/etc.

- Elton

----- Original Message -----
From: "Eric Hill" <Eric.Hill@[...].COM> 
To: <DOTNET@[...].COM> 
Sent: Thursday, November 15, 2001 2:34 PM
Subject: [DOTNET] C# Office add-in woes


>  Hey,
> 
>  I am running RC0.  I ran the "Shared add-in" project wizard to create the
boilerplate for an addin.  I am using early-bound calls to add a command bar
(which is successful) and then add a button to it (throws ArgumentException,
"The parameter is invalid", no info on which parameter).  Here is my code:
> 
>          try
>          {
>                  m_ExcelApp = (Excel.Application) appObject;
>                  m_AppType = Type.GetTypeFromProgID( "Word.Application" );
>                  string barName = "MyBar10";
>                  string btnName = "Button";
>                  bool bMenuBar = false;
>                  bool bTemp = false;
>                  bool bTemp2 = false;
>                  Office.CommandBar cmdBar;
>                  Office.CommandBarControl cmdBarCtrl;
>                  int id = 0;
>                  int before = 0;
> 
>                  // This one works
>                  cmdBar = m_ExcelApp.CommandBars.Add( barName,
MsoBarPosition.msoBarFloating,
>                          bMenuBar, bTemp );
> 
>                  // This one fails - "The parameter is invalid"
>                  cmdBarCtrl = cmdBar.Controls.Add(
MsoControlType.msoControlButton, id,
>                          btnName, before, bTemp2 );
>                  // Kaboom!
>          }
>          catch( System.Exception e )
>          {
>                  Trace.WriteLine( e.Message );
>          }
> 
>  I have tried about two dozen variations of the cmdBar.Controls.Add method,
from setting all the parameters after the first to null (they are optional
parameters after all), to no avail.  Anyone have any suggestions?  Switch to
VB ;-)?  I may try late-bound calls next.
> 
>  Thanks,
> 
>  Eric
> 
>  You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>  subscribe to other DevelopMentor lists at http://discuss.develop.com.
> 

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
Thread:
Eric Hill
Elton Wells

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved