Hi Joe,
I checked the path under properties and confirmed that it references the GAC
directory. (i.e. For Excel - path refers to
c:\Windows\assembly\GAC\Microsoft.Office.Interop.E xcel\...\Microsoft.Office.Interop.Excel.dll).
In my previous email, I referred to the wrong object library. I meant to
say that I added a reference to "Microsoft Excel 11.0 Object Library".
Under references, in addition to the Excel interop assembly, I see
Microsoft.Office.Core and VBIDE, but I don't see stdole. Is that a problem?
Thanks for all the help.
Mansi
"Joe Mayo" wrote:
[color=blue]
> Hi Mansi,
>
> Right-click on the reference under the References folder in Solution
> Explorer and select Properties. The path should lead to the
> %windir%\assembly\gac\.... directory. If you are pointing to something
> local, that local directory will show up.
>
> I noticed that you referenced the "Access" PIA, but are writing an alias for
> Excel. It seems like it shouldn't work. IIRC, the PIA namespace is not the
> same as a VS.NET auto-generated interop assembly. So, if you are still able
> to reference Microsoft.Office.Interop.Excel, then it seems like you still
> have the old auto-generated interop assembly in your references list. You
> should delete all the old interop assemblies.
>
> I remember having this problem back when I migrated from interop assemblies
> to PIAs. It was very difficult to get the interop assemblies out of the
> reference list. I removed all of the interop assemblies and PIA references
> from the project, went to the file system and deleted all of the
> auto-generated interop assemblies, and then re-added PIAs. Remember that
> generating interop assemblies also generates interop assemblies for all of
> it's dependent type libraries. So, in addition to the Excel interop
> assembly, you get Microsoft.Office.Core, stdole, and VBIDE. When you do
> this, look at the Path property, described above, to verify that you are
> referencing the PIA in the GAC.
>
> Joe
> --
>
http://www.csharp-station.com
>
> "Mansi" <Mansi@discussions.microsoft.com> wrote in message
> news:7327F4EA-5D40-43E1-B724-0732850CE4B3@microsoft.com...[color=green]
> > I followed the steps listed on the MSDN site to install the PIAs for[/color]
> Office[color=green]
> > 2003. I'm assuming they were installed successfully.
> >
> > In my c# .NET project, I added a reference to "Microsoft Access 11.0[/color]
> Object[color=green]
> > Library". Also, I added the following lines to the end of the list of[/color]
> using[color=green]
> > directives: using Excel = Microsoft.Office.Interop.Excel;
> > using System.Reflection;
> >
> > How do I confirm Visual Studio .NET is actually using the PIAs and not
> > generating its own interop assembly for the project?
> >
> > Thanks for all the help.
> >
> > Mansi
> >
> >
> >
> >
> >
> > "Joe Mayo" wrote:
> >[color=darkred]
> > > VSTO == Visual Studio Tools for Office. It ships with VS.NET Architect[/color][/color]
> or[color=green][color=darkred]
> > > you can buy it as a separate package. It allows you to automate Excel[/color][/color]
> and[color=green][color=darkred]
> > > Word applications with managed code. The programming model reminds me[/color][/color]
> of[color=green][color=darkred]
> > > ASP.NET with code-behind, where you can use Excel or Word as your UI.[/color][/color]
> The[color=green][color=darkred]
> > > only problem I had with it was that it supported only a single document[/color][/color]
> and[color=green][color=darkred]
> > > in the project I was working on, the customer needed to open multiple
> > > instances at the same time. However, if your requirements allow you to[/color][/color]
> work[color=green][color=darkred]
> > > with a single document, this is an excellent way to develop Office apps.
> > >
> > > If you are not using VSTO, Primary Interop Assemblies (PIAs) are the way[/color][/color]
> to[color=green][color=darkred]
> > > go. They are released by Microsoft and strong named and will save you[/color][/color]
> many[color=green][color=darkred]
> > > headaches. If someone should choose to generate their own interop
> > > assemblies, a whole new world of problems opens up, so I don't recommend[/color][/color]
> it.[color=green][color=darkred]
> > > For example, in self-generated interop assemblies, the SinkHelper[/color][/color]
> methods[color=green][color=darkred]
> > > are generated with private accessibility. You need these to be public[/color][/color]
> in[color=green][color=darkred]
> > > order to receive callbacks for Office document events. This requires[/color][/color]
> you to[color=green][color=darkred]
> > > disassemble the assembly, make the SinkHelper's public, and reassemble[/color][/color]
> the[color=green][color=darkred]
> > > assembly. PIAs save you all this hassle and more.
> > >
> > > You can do nearly everything you want with Excel, including putting data[/color][/color]
> in[color=green][color=darkred]
> > > the spread-sheet and formatting it as you like, pulling information out,
> > > capturing spreadsheet events, and more. The recorder macro is your[/color][/color]
> friend[color=green][color=darkred]
> > > because you can do what you want, generate the code, and examine the[/color][/color]
> code to[color=green][color=darkred]
> > > see what you need to do in C#.
> > >
> > > Joe
> > > --
> > >
http://www.csharp-station.com
> > >
> > > "Mansi" <Mansi@discussions.microsoft.com> wrote in message
> > > news:0F5C6BF7-70F4-4C75-BDD7-76676143F503@microsoft.com...
> > > > I've done some reading on PIA's and know that they are available for
> > > download
> > > > for office XP, but what is VSTO?
> > > >
> > > > Can excel automation be used so that I can export data from Visual c#[/color][/color]
> ..NET[color=green][color=darkred]
> > > > to an excel worksheet? What I'm looking to do is export data from a[/color][/color]
> grid[color=green][color=darkred]
> > > in
> > > > C# to excel such that the data is nicely formated and easy to read.[/color][/color]
> (I'm[color=green][color=darkred]
> > > > assuming that the "Record Macro" function in Excel will help simplify[/color][/color]
> the[color=green][color=darkred]
> > > > code for me). Is this something that's very complicated to do once I[/color][/color]
> have[color=green][color=darkred]
> > > > installed the Office XP PIAs?
> > >
> > >
> > >[/color][/color]
>
>
>[/color]