Bug or not !!?? 
Author Message
 Bug or not !!??

I have som projects that uses com interface. I have let the Visual
studio convert my projects and found a problem I can not solve.

I think it is a bug in the #import in VC7.

This "pSheets" works in VC6 but is empty in VC7
WorksheetsPtr pSheets = pBook->Worksheets;
 "pSheets" is NULL on VC7 and the queryinterface returns
E_NOINTERFACE

What is wrong and how to correct it !!!???
Please can someone verify
Regards
Stefan Gartz

******
// Test2.cpp
#include <afxwin.h>         // MFC core and standard components

#import "C:\Program\Microsoft Office\Office\MSO9.DLL"  
no_namespace  rename("RGB", "RBGOFFICE")
#import "C:\Program\Delade filer\Microsoft Shared\VBA\VBA6
\VBE6EXT.OLB" no_namespace
#import "C:\Program\Microsoft Office\Office\excel9.olb" rename
("RGB", "RBGXL") rename("DialogBox", "DialogBoxXL") rename
("CopyFile", "CopyFileXL") rename("ReplaceText", "ReplaceTextXL")

void Test()
{
using namespace Excel;
_ApplicationPtr pXL("Excel.Application");
WorkbooksPtr pBooks = pXL->Workbooks;
pBooks->Open("D:\\Projekt\\ProjRoot\\Test2\\ExcelTest.xls");
_WorkbookPtr pBook = pBooks->Item[1];
/* */
// Works on VC6 but not on VC7  
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<     E_NOINTERFACE
WorksheetsPtr pSheets = pBook->Worksheets;  
long sheets = pSheets->Count;

Quote:
}

class CTest2App : public CWinApp
{
public:
        CTest2App();
        public:
        virtual BOOL InitInstance();
        DECLARE_MESSAGE_MAP()
Quote:
};

BEGIN_MESSAGE_MAP(CTest2App, CWinApp)
END_MESSAGE_MAP()
CTest2App::CTest2App(){}
struct InitOle {
  InitOle()  { ::CoInitialize(NULL); }
  ~InitOle() { ::CoUninitialize();   }
Quote:
} _init_InitOle_;      

CTest2App theApp;
BOOL CTest2App::InitInstance()
{
        CWinApp::InitInstance();
        Test();
        return FALSE;
Quote:
}



Wed, 23 Feb 2005 03:07:13 GMT  
 Bug or not !!??


Quote:
> I have som projects that uses com interface. I have let the Visual
> studio convert my projects and found a problem I can not solve.

> I think it is a bug in the #import in VC7.

> This "pSheets" works in VC6 but is empty in VC7
> WorksheetsPtr pSheets = pBook->Worksheets;
>  "pSheets" is NULL on VC7 and the queryinterface returns
> E_NOINTERFACE

> What is wrong and how to correct it !!!???
> Please can someone verify
> Regards
> Stefan Gartz

> ******
> // Test2.cpp
> #include <afxwin.h>         // MFC core and standard components

> #import "C:\Program\Microsoft Office\Office\MSO9.DLL"
> no_namespace  rename("RGB", "RBGOFFICE")
> #import "C:\Program\Delade filer\Microsoft Shared\VBA\VBA6
> \VBE6EXT.OLB" no_namespace
> #import "C:\Program\Microsoft Office\Office\excel9.olb" rename
> ("RGB", "RBGXL") rename("DialogBox", "DialogBoxXL") rename
> ("CopyFile", "CopyFileXL") rename("ReplaceText", "ReplaceTextXL")

> void Test()
> {
> using namespace Excel;
> _ApplicationPtr pXL("Excel.Application");
> WorkbooksPtr pBooks = pXL->Workbooks;
> pBooks->Open("D:\\Projekt\\ProjRoot\\Test2\\ExcelTest.xls");
> _WorkbookPtr pBook = pBooks->Item[1];
> /* */
> // Works on VC6 but not on VC7
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< E_NOINTERFACE
> WorksheetsPtr pSheets = pBook->Worksheets;
> long sheets = pSheets->Count;
> }

This vaguely remembers me of a problem I had.
IIRC, I solved it by using

long sheets = pWorkbook->GetSheets()->Count;
for (long i = 1;i<=sheets; i++) {
  _WorksheetPtr pSheet = pBook->GetSheets()->Item[1L];
  // ...

Quote:
}

// Luc K


Fri, 25 Feb 2005 22:40:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Possible bug when (not) implementing abstract methods

2. A compiler bug or not?

3. ANSI C - compiler bug or not

4. A compiler bug or not

5. weird bug - OLECMDID_OPEN not working

6. WTL - ATL - BUG: WM_OCC_INITNEW not handled ( anywhere ! )

7. Bug: NM_RDBLCLK not received in Treeview Control

8. Common controls, a bug, think not...

9. Bug or not wstring

10. IMPLEMENT_DYNAMIC_T bug (or not using it right?)

11. Bug or not?

12. VC5.0 Bug.....class not showing up...

 

 
Powered by phpBB® Forum Software