LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Does CoGetInstanceFromFile work with worksheets?

What is wrong with the following code?

CoInitializeEx(NULL, COINIT_MULTITHREADED); int i(01);
for(; i < argc; i++) {
static MULTI_QI interfaces[01] = {&__uuidof(_Workbook), NULL, 00}; // i
tried also IID_IDispatch, does not work either
HRESULT code;
wcout << _T("Trying to open file ") << argv[i] << _T(" ... "); // argv[01]
== "sheet.xls"
if(SUCCEEDED(code = CoGetInstanceFromFile(NULL, NULL, NULL, CLSCTX_ALL,
STGM_READ, argv[i], 01, interfaces))) {
cout << _T("opened.") << endl;
interfaces-pItf-Release(); }
else {
wcout << _T("failed.") << endl;
HandleCOMError(code); } // code returned is E_NOINTERFACE


 
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
How to work with Many Worksheets chrisk Excel Worksheet Functions 3 September 11th 08 06:14 AM
How Do I Tie Worksheets to one Work book? Bettine S Cavanaugh Excel Worksheet Functions 2 March 31st 08 04:01 AM
Have 2 worksheets work together Gardengramma Excel Worksheet Functions 1 March 21st 08 11:06 PM
Macro to work only on selected worksheets [email protected] Excel Discussion (Misc queries) 3 January 22nd 07 07:14 PM
UDF doesn't work in old worksheets BartDesc Excel Discussion (Misc queries) 4 August 12th 06 10:37 PM


All times are GMT +1. The time now is 08:03 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"