VB .NET Excel Builtin Property Access fails

  • Thread starter Mark Nethercott
  • Start date
M

Mark Nethercott

I've already asked this question in the microsoft.public.dotnet.languages.vb
forum, but it has stumped them.
I wondered if anyone had tried to access/set the workbook properties using
VB .NET?

When I try it, I get the following failure when trying to access the builtin
properties;

An unhandled exception of type 'System.InvalidCastException' occurred in
resultsoutput.dll
Additional information: Specified cast is not valid.

In general terms the code is constructed as follows;

ModuleA
Public xlWb As Excel.Workbook

ModuleB
SubA
Dim prps As Microsoft.Office.Core.DocumentProperties
prps = DirectCast(xlWb.BuiltinDocumentProperties,
Microsoft.Office.Core.DocumentProperties)

This is using;
Framework 1.1
Excel 2002 SP3
Reference to COM Microsoft Excel 10.0 Object Library (Version 1.4)

I've been following the article by Ken Getz
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto20
03_ta/html/ExcelObj.asp)
which suggests the code should work.
Ken's article refers to Excel 2003, but all the objects he references are
also in the
Microsoft Excel 10 COM object. I wondered whether this was a bug in the 2002
COM or I've missed something in my code.
 

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

Top