View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Uncle Martin Uncle Martin is offline
external usenet poster
 
Posts: 3
Default Imports Excel = Microsoft.Office.Interop.Excel doesn't work

I am "replying" to my own post to supply an addendum:

After playing around a bit, I find that this line of code *does* work when
you are using one of the office templates, e.g., the Excel Workbook Visual
Studio template. However, I was trying to follow an example in the book,
"Visual Studio Tools for Office Using Visual Basic 2005" by Eric Carter and
Eric Lippert. The example involves creating an automation add-in using a
Visual Basic Class Library template. For some reason, in that environment
(on my system), the command is not recognized. Later in the code example,
the following line appears:

Dim r2 As Excel.Range = number2

As you may expect, the compiler balks at that, also.

Is there some reason that you cannot access this namespace from a class
library project? If that is the case, why did the authors include that line
of code in their example? Is it just a typo, or has something changed
because I am using Vista? Did I miss some other setting that must be
included in order to access it?

Thanks,

Marty

"Uncle Martin" wrote:

Hi,

I am trying to learn VSTO programming. I have Windows Vista installed.

When I type Imports Excel = Microsoft.Office.Interop.Excel, Intellisense
does not recognize anything after Microsoft. A green squiggly appears under
the statement. The tool tip says, "Namespace or type specified in the
Imports 'Microsoft.Office.Interop.Excel' doesn't contain any public member or
cannot be found. Make sure the namespace or the type is defined and contains
at least one public member. Make sure the imported element name doesn't use
any aliases."

I downloaded, unblocked, and installed the Office PIA's, but I still get the
same result. Is this another dirty Vista trick, or have I missed something?

Marty