Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default C# Automation problem

I don't have VS 2005 Tools for MS Office, so I am trying to do this the old
fashioned way with automation.

I have created the Excel application, and am trying to set the document
properties, such as Title and Author. To that end I have a reference to
Microsoft.Office.Core and am trying to assign
workbook.BuiltinDocumentProperties to a DocumentProperties object (with the
appropriate casting).

I get this exception:

System.InvalidCastException : Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Core.DocumentProperties'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).

Help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default C# Automation problem

In Excel the workbook must be open to access its document properties.
The syntax would be something like this using Automation...

Dim strAuthor as String
strAuthor = AppXL.Workbooks("Important").BuiltinDocumentProper ties(3)

However, or also, MS supplies a .dll (Dsofile.dll) that allows one to read
and to edit document properties that are associated with Microsoft
Office files. I've used it and it works, but I have found no need for it.
Find it here...
http://support.microsoft.com/kb/224351/en-us
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jamie Oglethorpe"

wrote in message .
I don't have VS 2005 Tools for MS Office, so I am trying to do this the old
fashioned way with automation.
I have created the Excel application, and am trying to set the document
properties, such as Title and Author. To that end I have a reference to
Microsoft.Office.Core and am trying to assign
workbook.BuiltinDocumentProperties to a DocumentProperties object (with the
appropriate casting).
I get this exception:

System.InvalidCastException : Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Core.DocumentProperties'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).

Help!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default C# Automation problem

Hi Jim,

I have a feeling I may have to do this in VB. I am translating Delphi code I
did about 5 years ago. Unfortunately the translation is not exact. Here is a
cut down versionof what I am doing. The app writes the contents of a data set
with several tables to a new Excel document. The Excel code is wrapped in a
base class that takes care of all the messy low level details. I am excluding
stuff like the application property and methods here.

....
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;
....
private Application excel = new Application();
....
string s = Excel.DefaultFilePath;
if (File.Exists(FileName))
File.Delete(FileName);
else if (File.Exists(s + "\\" + FileName))
File.Delete(s + "\\" + FileName);
Excel.SheetsInNewWorkbook = 1;
Book = Excel.Workbooks.Add(Type.Missing);
Sheet = (Worksheet)Book.Worksheets[1];
DocumentProperties prop =
(DocumentProperties)Book.BuiltinDocumentProperties ;
// this is the line that crashes
prop["Title"].Value = Title;
....

"Jim Cone" wrote:

In Excel the workbook must be open to access its document properties.
The syntax would be something like this using Automation...

Dim strAuthor as String
strAuthor = AppXL.Workbooks("Important").BuiltinDocumentProper ties(3)

However, or also, MS supplies a .dll (Dsofile.dll) that allows one to read
and to edit document properties that are associated with Microsoft
Office files. I've used it and it works, but I have found no need for it.
Find it here...
http://support.microsoft.com/kb/224351/en-us
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jamie Oglethorpe"

wrote in message .
I don't have VS 2005 Tools for MS Office, so I am trying to do this the old
fashioned way with automation.
I have created the Excel application, and am trying to set the document
properties, such as Title and Author. To that end I have a reference to
Microsoft.Office.Core and am trying to assign
workbook.BuiltinDocumentProperties to a DocumentProperties object (with the
appropriate casting).
I get this exception:

System.InvalidCastException : Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Core.DocumentProperties'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).

Help!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default C# Automation problem

No help available from here.

Jim Cone
http://www.officeletter.com/blink/specialsort.html


"Jamie Oglethorpe"
wrote in message
Hi Jim,
I have a feeling I may have to do this in VB. I am translating Delphi code I
did about 5 years ago. Unfortunately the translation is not exact. Here is a
cut down versionof what I am doing. The app writes the contents of a data set
with several tables to a new Excel document. The Excel code is wrapped in a
base class that takes care of all the messy low level details. I am excluding
stuff like the application property and methods here....
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;...
private Application excel = new Application();...
string s = Excel.DefaultFilePath;
if (File.Exists(FileName))
File.Delete(FileName);
else if (File.Exists(s + "\\" + FileName))
File.Delete(s + "\\" + FileName);
Excel.SheetsInNewWorkbook = 1;
Book = Excel.Workbooks.Add(Type.Missing);
Sheet = (Worksheet)Book.Worksheets[1];
DocumentProperties prop =
(DocumentProperties)Book.BuiltinDocumentProperties ;
// this is the line that crashes
prop["Title"].Value = Title;



"Jim Cone" wrote:
In Excel the workbook must be open to access its document properties.
The syntax would be something like this using Automation...
Dim strAuthor as String
strAuthor = AppXL.Workbooks("Important").BuiltinDocumentProper ties(3)
However, or also, MS supplies a .dll (Dsofile.dll) that allows one to read
and to edit document properties that are associated with Microsoft
Office files. I've used it and it works, but I have found no need for it.
Find it here...
http://support.microsoft.com/kb/224351/en-us-
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jamie Oglethorpe"

wrote in message .
I don't have VS 2005 Tools for MS Office, so I am trying to do this the old
fashioned way with automation.
I have created the Excel application, and am trying to set the document
properties, such as Title and Author. To that end I have a reference to
Microsoft.Office.Core and am trying to assign
workbook.BuiltinDocumentProperties to a DocumentProperties object (with the
appropriate casting).
I get this exception:
System.InvalidCastException : Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Core.DocumentProperties'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
Help!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default C# Automation problem

Thanks anyway.

"Jim Cone" wrote:

No help available from here.

Jim Cone
http://www.officeletter.com/blink/specialsort.html


"Jamie Oglethorpe"
wrote in message
Hi Jim,
I have a feeling I may have to do this in VB. I am translating Delphi code I
did about 5 years ago. Unfortunately the translation is not exact. Here is a
cut down versionof what I am doing. The app writes the contents of a data set
with several tables to a new Excel document. The Excel code is wrapped in a
base class that takes care of all the messy low level details. I am excluding
stuff like the application property and methods here....
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Core;...
private Application excel = new Application();...
string s = Excel.DefaultFilePath;
if (File.Exists(FileName))
File.Delete(FileName);
else if (File.Exists(s + "\\" + FileName))
File.Delete(s + "\\" + FileName);
Excel.SheetsInNewWorkbook = 1;
Book = Excel.Workbooks.Add(Type.Missing);
Sheet = (Worksheet)Book.Worksheets[1];
DocumentProperties prop =
(DocumentProperties)Book.BuiltinDocumentProperties ;
// this is the line that crashes
prop["Title"].Value = Title;



"Jim Cone" wrote:
In Excel the workbook must be open to access its document properties.
The syntax would be something like this using Automation...
Dim strAuthor as String
strAuthor = AppXL.Workbooks("Important").BuiltinDocumentProper ties(3)
However, or also, MS supplies a .dll (Dsofile.dll) that allows one to read
and to edit document properties that are associated with Microsoft
Office files. I've used it and it works, but I have found no need for it.
Find it here...
http://support.microsoft.com/kb/224351/en-us-
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Jamie Oglethorpe"

wrote in message .
I don't have VS 2005 Tools for MS Office, so I am trying to do this the old
fashioned way with automation.
I have created the Excel application, and am trying to set the document
properties, such as Title and Author. To that end I have a reference to
Microsoft.Office.Core and am trying to assign
workbook.BuiltinDocumentProperties to a DocumentProperties object (with the
appropriate casting).
I get this exception:
System.InvalidCastException : Unable to cast COM object of type
'System.__ComObject' to interface type
'Microsoft.Office.Core.DocumentProperties'. This operation failed because the
QueryInterface call on the COM component for the interface with IID
'{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
Help!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel automation problem Arvi Laanemets Excel Programming 3 April 13th 06 09:22 AM
Office automation problem vba_nerd Excel Programming 0 April 6th 06 11:31 AM
C++ automation problem [email protected] Excel Programming 0 March 24th 06 05:48 PM
Excel Automation Problem With Add-Ins pagates Excel Programming 4 October 6th 05 05:18 PM
Automation problem Tim Long Excel Programming 5 July 20th 05 03:51 PM


All times are GMT +1. The time now is 12:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"