« Return to Thread: Accessing Excel from ISE Eiffel

Re: Re: Accessing Excel from ISE Eiffel

by Peter Gummer-2 :: Rate this Message:

Reply to Author | View in Thread

Anders wrote:

> I will then try to build my own IA. Do you know were to start to read
> about that?

Using Microsoft's PIA is easier, if it works (which I think it will).

But if you do want to build your own IA, it's not hard. The first question is: what is the oldest version of Excel that you need to support? Microsoft recommends always using the exact PIA for the version of Excel that it is calling; but in practice there seems to be no problem using an IA built for an older version of Excel to call a newer version of Excel (unless you want to call a feature available in the newer version that did not exist in the old version, which won't work, of course, because the feature does not exist in the old IA).

So, here's how to build the IAs:
  1.. Get a machine with the oldest version of Excel that you are going to support. (Maybe you already have the correct version installed. If not, don't install an old version over the top of a new version!)
  2.. Decide what name you want to give the IAs. I chose assembly names that clearly identified the version of Office and that they were not Microsoft's PIAs, e.g., Anders.Interop.Excel2000.dll. Note that Microsoft uses these names:
    a.. Office.dll, for things shared by different Office applications, has the namespace Microsoft.Office.Core.

    b.. Microsoft.Vbe.Interop.dll, for the Visual Basic projects editor, has the namespace Microsoft.Vbe.Interop.

    c.. Microsoft.Office.Interop.Excel.dll, for Excel-specific stuff, has the namespace Microsoft.Office.Interop.Excel.

  3.. Open a Visual Studio .NET command prompt.
  4.. Run tlbimp.exe, Microsoft's tool for generating IAs from a COM type library, once for each IA. For example, you might run these commands on a machine with Excel 2000 installed:
    a.. tlbimp "C:\Program Files\Microsoft Office\Office\MSO9.DLL" /out:Anders.Interop.Office2000.dll /sysarray
    b.. tlbimp "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" /out:Anders.Interop.VBIDE2000.dll /reference:Anders.Interop.Office2000.dll /sysarray
    c.. tlbimp "C:\Program Files\Microsoft Office\Office\Excel9.OLB" /out:Anders.Interop.Excel2000.dll /reference:Anders.Interop.Office2000.dll /reference:Anders.Interop.VBIDE2000.dll /sysarray

That's it. There are other options you can change (choosing your own namespace, strong-naming them with your own key, etc.), but those are the basic steps.

Don't install these IAs in the GAC of development or deployment machines. When deploying an application, copy the IAs to the deployment directory, with the rest of the application.
A couple of Office Interop references that I found useful:

[1] http://www.samspublishing.com/articles/printerfriendly.asp?p=27219, "The Essentials for Using COM in Managed Code", Adam Nathan.

[2] "Microsoft .NET Development for Microsoft Office", Andrew Whitechapel, Microsoft Press, 2005.


- Peter Gummer

[Non-text portions of this message have been removed]


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/eiffel_software/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:eiffel_software-digest@...
    mailto:eiffel_software-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    eiffel_software-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

 « Return to Thread: Accessing Excel from ISE Eiffel

LightInTheBox - Buy quality products at wholesale price