Link to home
Start Free TrialLog in
Avatar of jribble
jribble

asked on

Upgrading C++ applications to use Office 2007

I have a C++ application in VS2005 that generates Excel spreadsheets.  We are upgrading to VS2008 and from Office 2003 to Office 2007.

The code to import the correct version of Office is pasted here:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//#define USE_MS_OFFICE_2000
//#define USE_MS_OFFICE_2002
#define USE_MS_OFFICE_2003

#if defined(USE_MS_OFFICE_97) // Office 97 (Office v8)

#import "c:\program files\microsoft office\office\mso97.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesXL")
#import "c:\program files\common files\microsoft shared\vba\vbeext1.olb" no_namespace
#import "c:\program files\microsoft office\office\Excel8.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces

#elif defined(USE_MS_OFFICE_2000)      // Office 2000 (Office v9)

#import "C:\Program Files\Microsoft Office\Office\mso9.dll" no_namespace rename("DocumentProperties", "DocumentPropertiesXL")
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" no_namespace
#import "C:\Program Files\Microsoft Office\Office\Excel9.olb" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") no_dual_interfaces

#elif defined(USE_MS_OFFICE_2002)      // Office XP (2002) (Office v10)

#import "C:\Program Files\Common Files\Microsoft Shared\office10\mso.dll" rename("DocumentProperties", "DocumentPropertiesXL") rename("RGB", "RBGXL")
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb"
#import "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" rename("DialogBox", "DialogBoxXL") rename("RGB", "RBGXL") rename("DocumentProperties", "DocumentPropertiesXL") rename("ReplaceText", "ReplaceTextXL") rename("CopyFile", "CopyFileXL") no_dual_interfaces

#elif defined(USE_MS_OFFICE_2003) // Office 2003 (Office v11) (Will give error (actually a warning) that you need W2K or higher to run the result)

#import "C:\Program Files\Common Files\Microsoft Shared\OFFICE11\mso.dll" rename("RGB", "MSRGB")
#import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" raw_interfaces_only, rename("Reference", "ignorethis"), rename("VBE", "testVBE")
#import "C:\Program Files\Microsoft Office\OFFICE11\excel.exe" exclude("IFont", "IPicture") rename("RGB", "ignorethis"), rename("DialogBox", "ignorethis"), rename("VBE", "testVBE"), rename("ReplaceText", "EReplaceText"), rename("CopyFile","ECopyFile"), rename("FindText", "EFindText"), rename("NoPrompt", "ENoPrompt") no_dual_interfaces

#else

#error Please define one of the USE_MS_OFFICE_xx definitions to select which MS Office version should be used.

#endif
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

I get the following error trying to compile:

1>.\ExcelExport.cpp(32) : fatal error C1083: Cannot open type library file: 'C:\Program iles\Microsoft Office\OFFICE11\excel.exe': No such file or directory

Does anyone know what the import statements for Office 2007 look like?

Thanks,

Joe
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>>> Cannot open type library file: 'C:\Program iles\Microsoft Office\OFFICE11

Firstly, you should take all error messages literally. So if you copied the original error message from your output window, the error message surely is right casue you probably have no folder named  'C:\Program iles' but only 'C:\Program Files'.

So correct the path specified in line 32 of export.cpp.
Avatar of jribble
jribble

ASKER

I think I copied the error incorrectly and dropped the F in "Program iles".  The error was not unexpected, I was just wondering if anyone was aware of the equivalent import statements for Office 2007.
As above: They should be the same...
Avatar of jribble

ASKER

The files were actually located in the OFFICE12 directory.  Once I made that adjustment, it compiled and worked fine.

#import "C:\\Program Files\\Common Files\\Microsoft Shared\\OFFICE12\\MSO.DLL"
#import "C:\\Program Files\\Microsoft Office\\OFFICE12\\EXCEL.EXE"