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
[DOTNET] C# Office add-in woes
by Eric Hill other posts by this author
Nov 15 2001 8:34PM messages near this date
Re: [DOTNET] Compression (was Who has built an app?) | Re: [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 ad
d a button to it (throws ArgumentException, "The parameter is invalid", no info on which par
ameter).  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.
Thread:
Eric Hill
Elton Wells

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