#import "F:\Office2000\Office\MSWORD9.OLB" rename_namespace("Word"),   raw_interfaces_only, named_guids 
using namespace Word;错误的提示是
e:\jing\wordadd\debug\msword9.tlh(11906) : warning C4003: not enough actual parameters for macro 'ExitWindows'
e:\jing\wordadd\debug\msword9.tlh(11906) : error C2059: syntax error : 'constant'
我用相同的办法引入OUTLOOK的OLB则成功添加。

解决方案 »

  1.   

    SYMPTOMS
    warning C4003: not enough actual parameters for macro 'ExitWindows' CAUSE
    This problem is actually caused by a macro defined in the Windows SDK header file Winuser.h. Winuser.h redefines ExitWindows() to map to the Win32 SDK API ExitWindowsEx(). This poses a problem for any C++ classes that need to implement a member function named ExitWindows(). The Word.Basic object exposes an automation method called ExitWindows(). When ClassWizard reads the type information contained in the Word type library (Wb70en32.tlb), it generates a class containing a member function called ExitWindows(). Attempting to compile this class generates the C4003 error. RESOLUTION
    Here are two ways to work around this problem. If your application doesn't make use of the ExitWindows() SDK function, you can undefine the macro byincluding the following line of code before the definition of the class that contains the ExitWindows() member function. 
       #undef ExitWindows 
    However, a more straightforward workaround is to rename the ExitWindows() member function for the problem class. For example, rename WordBasic::ExitWindows() to WordBasic::_ExitWindows(). You can write line before #import:
    #undef ExitWindows 
      

  2.   

    多谢,但是还是编译通不过,如下
    StdAfx.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat "_CLSID_Application"
      

  3.   

    初始化com了吗?我有个在Word中加按扭的,你要的话,我给你。
      

  4.   

    我用的是ATL,多谢,[email protected]
      

  5.   

    add line #undef ExitWindows before #import statement
    RebuildAll!!
    I pass it!!!
      

  6.   

    我的方法:
    #import "E:\Program Files\Microsoft Office\Office\MSWord9.OLB" \
    rename("DialogBox", "WordDialogBox") \
    rename("ExitWindows", "WordExitWindows") \
    rename("RGB", "WordRGB") \
    no_auto_exclude
    #endif
      

  7.   

    那你能不能把你IMPORT 的方法贴一下,我是这样的
    #import "F:\Office2000\Office\mso9.dll" rename_namespace("Office"), named_guids
    using namespace Office;#import "D:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" rename_namespace("vba")#import "f:\office2000\Office\MSWORD9.OLB" rename("ExitWindows","_ExitWindows") rename_namespace("word"), named_guids
    using namespace word;
    编译后是
    StdAfx.obj : fatal error LNK1179: invalid or corrupt file: duplicate comdat "_IID_ThreeDFormat"
      

  8.   

    zswzwy:
    可以发代码给我吗,[email protected]
    谢谢
      

  9.   

    have you passed it??
    My import statement is:#import "F:\Program Files\Microsoft Office\Office\MSWORD9.OLB" rename_namespace("Myword"), rename("ExitWindows", "_ExitWindows"), raw_interfaces_only, named_guids
    using namespace Myword;or
    #undef ExitWindows 
    #import "F:\Program Files\Microsoft Office\Office\MSWORD9.OLB" rename_namespace("Myword"), raw_interfaces_only, named_guids
    using namespace Myword;