Incomplete Office 2007 install? Where are .NET PIAs for Excel? Need VSTO?

J

John Brock

I may have botched an install of Office Professional 2007, or I
may have a different problem. I hope someone will be able to tell
me which, and if the problem was the install, give me some advice
about reinstalling and getting it right.

What I want to do is use Visual Studio to write a VB.NET app that
reads and writes Excel workbooks. I have already done this in a
corporate setting (using VS 2005 Team Edition), but now I need to
do it on my home computer. In the corporate setting, if I wanted
the code in a module or class to be able to access Excel, I inserted
the following statement at the beginning of the file:

Imports Excel = Microsoft.Office.Interop.Excel

This didn't work at home, where I was using Excel 2002 and Visual
Studio 2008 Express. With a little research I found I needed these
things called PIAs (Primary Interop Assemblies), that came with
Office 2003 and 2007, but were not installed by default:

Office 2003 and later versions of Office include PIAs with
the Office Setup program. The Office PIAs may be installed
with the Office Setup program provided that your computer
has the .NET Framework 1.1 or a later version of the .NET
Framework already installed. You can distribute the Office
PIAs by using the Microsoft Office Primary Interop Assemblies
(PIAs) redistributable.

http://support.microsoft.com/kb/840585

So I bought a copy of Office Professional 2007 (I was overdue
anyway) and installed it, but the VB statement above still gives
me an error message saying that:

Namespace or type specified in the Imports
'Microsoft.Office.Interop.Excel' doesn't contain any public
member or cannot be found.

I see two possibilities:

1) VS 2008 Express just doesn't cut it. I know that with VS 2008
Professional you get something called Visual Studio Tools for
Office, but I was under the impression that having the PIAs installed
was enough to get you connected to Excel, and that all VSTO added
was a bunch of templates and tools that made Office programming
easier. But perhaps I was wrong, and VS 2008 Express is not capable
of using the PIAs? I can get a copy of VS 2008 Professional, but
I would rather use Express if possible. And in any case I am not
certain that is the problem. The other possibility is:

2) There were two CDs in the Office Professional 2007 box, but only
one was used in the installation process. So what is on Disc 2,
and why wasn't it asked for? I'm concerned because I tried to do
a custom install that would install *everything*, including the
PIAs, but the procedure was kind of confusing. I was given a tree
with the various Office components, and a bunch of dropdown choices,
in particular "Run from My Computer" and "Run All from My Computer".
(This is from memory, so I may be a bit off). The installation
help said that if you chose "Run All" then all the subcomponents
would also be installed, so I checked that at the highest level
(Office), and the boxes for all the subcomponents turned white
(some had been gray), and by my reading of the help this is what
I wanted. But perhaps I did a minimum install, rather than a
maximum? So it would be very very helpful to know:

2a) How can I find out if the PIAs in fact were installed?

2b) If I need to do a reinstall, how do I make sure I get
it right this time?

Thanks in advance for any help you can give me!
 
P

Phil Wilson

Each feature in Office 2007 (Excel, Outlook etc) has a sub-feature called
..NET Programmability Support. Go to Add/Remove Programs and modify the
installed features to add the ones you need, plus that will tell you if they
are already installed or not (and whether VS 2008 cuts it or not).
 
J

John Brock

Thanks for the quick response! I already figured out my problem
-- it turns out you need to explicitly add a reference to Excel to
the project (using Project -> Add Reference); it doesn't just happen
automatically. In the corporate environment there are people who
do this sort of thing up for you, so you don't see everything that
is involved!

I am wary of playing with Add/Remove Programs, because my usual
experience is that when you click on a button a program goes away.
Are you saying I should hit the Change button for the Microsoft
Office Professional 2007 entry, and find out what's underneath it?
I tried doing that on a Limited account (to be safe) and the Office
Setup program came up, which scared me, so I canceled. But it
would be good to be able to explore programs and see which components
are installed, if it can be done safely.

BTW, your book looks interesting. I am in the market for such a
book, so it's now on my short list!

Each feature in Office 2007 (Excel, Outlook etc) has a sub-feature called
.NET Programmability Support. Go to Add/Remove Programs and modify the
installed features to add the ones you need, plus that will tell you if they
are already installed or not (and whether VS 2008 cuts it or not).
 
P

Phil Wilson

Doing a change from ARP for Office won't do much - it will offer you a viiew
of the installed features in a treeview. You can see the .NET
Programmability choice, and cancel out without doing anything.

I generally trust Microsoft product installations - from my experience
they're fine - but you're right, setups often don't get the attention they
deserve and are thrown togetherin a rush at the end of the development
cycle.

--
Phil Wilson
Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972


John Brock said:
Thanks for the quick response! I already figured out my problem
-- it turns out you need to explicitly add a reference to Excel to
the project (using Project -> Add Reference); it doesn't just happen
automatically. In the corporate environment there are people who
do this sort of thing up for you, so you don't see everything that
is involved!

I am wary of playing with Add/Remove Programs, because my usual
experience is that when you click on a button a program goes away.
Are you saying I should hit the Change button for the Microsoft
Office Professional 2007 entry, and find out what's underneath it?
I tried doing that on a Limited account (to be safe) and the Office
Setup program came up, which scared me, so I canceled. But it
would be good to be able to explore programs and see which components
are installed, if it can be done safely.

BTW, your book looks interesting. I am in the market for such a
book, so it's now on my short list!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top