PC Review


Reply
Thread Tools Rate Thread

Doing the Excel from .NET COM

 
 
Pavils Jurjans
Guest
Posts: n/a
 
      5th Apr 2006
Hello,

I have the following task: I need to create an Excel macro that would pass
the Worksheet object to COM component, and the code of COM component then
has full control what to do with the Excel Worksheet data - in my case, it
would read the data from cells and build XML file to be stored in specified
location. The COM component would be written in .NET, and registered in
system with COM wrapper.

I want to use external COM component, because I'd hate to write all the
XML-building code in VBA, and also because I have some code handy .NET
classes that can be reused.

Here's the code that I'm currently using:

C# code for the class that will be wrapped as COM:

using System;
namespace ExcelXML {
public class Report {
public string Generate(object o) {
return o.GetType()+"";
}
}
}

Excel macro, that is using the COM:

Sub Macro()
Dim o
Set o = CreateObject("ExcelXML.Report")
MsgBox o.Generate(ActiveWorkbook.ActiveSheet)
End Sub

To make all this work, you need to register the Com Callable Wrapper proxy.
for the .NET dll to make it available for Excel!

When the macro is launched in Excel, the returned type is
"System.__ComObject". I couldn't find any reference on this type of object
in .NET manuals. Everywhere I read about working with com objects, it is
being said that one needs to create a "wrapper for the COM component using
the TLBImp utility". Well, I certainly don't have any Excel Worksheet COM
DLL that could be used to create a wapper, and I doubt it would help,
because the Worksheet object has number of properties that, in turn, are
other type of objects, and, perhaps, to work with them, I'd need to create
wrappers for those, too!

Maybe I am just going the wrong way here. Maybe there is another suggested
method, how to make external .NET code control objects like Excel worksheet?

I'd be very happy for any advice

With kind regards,

Pavils Jurjans


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste failed in excel file migrated from Excel 2003 to Excel Handong Chen Microsoft Excel Crashes 1 4th Mar 2010 07:05 PM
Application coded in excel 2000 when used in excel 2003 excel doesnot perform well and takes double the time to give the output Prince Microsoft Excel Programming 4 17th Feb 2009 04:05 PM
Problem with Excel reports ::::Excel 2003 Migration To Excel 2007 =?Utf-8?B?c2hhc2hhbmsga3Vsa2Fybmk=?= Microsoft Excel Programming 0 5th Oct 2007 11:26 AM
Excel 2003 crashes loading excel files created Excel 2000 =?Utf-8?B?SmVmZiBMZXdpbiAgQXVzdHJhbGlh?= Microsoft Excel Misc 0 27th Jun 2005 05:20 AM
Why my Excel 2003 don't open excel files by duble click on excel . =?Utf-8?B?VmFseQ==?= Microsoft Excel Crashes 1 20th Jan 2005 04:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:34 PM.