Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Define Excel Addin programatically

Hi,
I am using C# to use Excel COM object to add and set up an add-in.
Here, I am using Late Binding concept. Following code allows me to just
open Excel from my program (just to prove it works).

object ExelAppObject;
ExcelAppType = Type.GetTypeFromProgID("Excel.Application");
ExelAppObject = Activator.CreateInstance(ExcelAppType);
objArray = new object[] {true};
retObj = ExcelAppType.InvokeMember("Visible",
BindingFlags.SetProperty,
null,
ExelAppObject ,
objArray);

Now, I want to setup the addin. So get the AddIns object collection
with following:

object addIns = ExcelAppType.InvokeMember("AddIns",
BindingFlags.GetProperty,
null,
ExelAppObject,
null);

At this point, I get the COM object returns to my code and now I try to
add the Add-In.

objArray = new object[] {xllPath};
object addIn = addIns.GetType().InvokeMember("Add",

BindingFlags.InvokeMethod,
null,
addIns,
objArray);

Where xllPath is the file name with the path. This throws an error
saying that remote object got an exception.

Anybody has an idea how to do this? Anyway, the Early Binding is not a
solution due to the version problem.

Many thanks

SAM



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Define Excel Addin programatically

Not exactly what you are asking for, but do you have a compelling reason to
use C# for this? I would personally create any add-in for Excel in VB6, for
the time being. C# is a pain in the #$#$ with com.....I would shy away
unless necessary. Aside from cross-process marshelling, it is plain flat
not convenient to use com objects in C#. Just my 2cents!

Bill Barclift

"samdesilva" wrote in message
...
Hi,
I am using C# to use Excel COM object to add and set up an add-in.
Here, I am using Late Binding concept. Following code allows me to just
open Excel from my program (just to prove it works).

object ExelAppObject;
ExcelAppType = Type.GetTypeFromProgID("Excel.Application");
ExelAppObject = Activator.CreateInstance(ExcelAppType);
objArray = new object[] {true};
retObj = ExcelAppType.InvokeMember("Visible",
BindingFlags.SetProperty,
null,
ExelAppObject ,
objArray);

Now, I want to setup the addin. So get the AddIns object collection
with following:

object addIns = ExcelAppType.InvokeMember("AddIns",
BindingFlags.GetProperty,
null,
ExelAppObject,
null);

At this point, I get the COM object returns to my code and now I try to
add the Add-In.

objArray = new object[] {xllPath};
object addIn = addIns.GetType().InvokeMember("Add",

BindingFlags.InvokeMethod,
null,
addIns,
objArray);

Where xllPath is the file name with the path. This throws an error
saying that remote object got an exception.

Anybody has an idea how to do this? Anyway, the Early Binding is not a
solution due to the version problem.

Many thanks

SAM



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Programatically adding macro to Excel - "ThisWorkbook" Aerojade Excel Discussion (Misc queries) 3 October 1st 08 12:53 PM
how to determine excel service pack programatically? Sonal Excel Discussion (Misc queries) 0 October 26th 06 06:58 AM
How to determine programatically if Excel is installed PeterH Excel Discussion (Misc queries) 2 March 29th 05 08:13 PM
Creating a PDF file programatically from Excel Chaplain Doug Excel Discussion (Misc queries) 0 December 16th 04 08:49 PM
Excel crashing when (programatically) adding past the 360th worksheet to a workbook Scott Lyon Excel Programming 2 August 14th 03 12:34 PM


All times are GMT +1. The time now is 04:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"