Home > Software engineering >  Help ah, operating in the VC2010 Word import MSWORD. Not generated after OLB MSWORD. H.
Help ah, operating in the VC2010 Word import MSWORD. Not generated after OLB MSWORD. H.

Time:09-23

According to vc operation word online tutorial I use class wizard import MSWORD. The OLB add type library of MFC class, I put all humans are derived, but why not
Msword. H this file, a great god for help.

CodePudding user response:

After the import, the generated not. H file, is called TLH and. Tli? File, and should be in the debug directory

CodePudding user response:

I was found on the debug directory msword. TLH file but this is how to do ah.
I am not the import, I am in class wizard click add MFC class from the type library select MSWORD. The OLB file will all classes of export to the project, but no MSWORD. H this file is what problem.

CodePudding user response:

Msword. This and TLH. H file, you can use the IDE to open

CodePudding user response:

I also met the same problem,
According to the online method in the class wizard to add file: "C: \ Program Files \ Microsoft Office \ OFFICE11 \ MSWORD OLE", then all the classes are added to the project, and then customize a class in adding the header file # include "MSWORD. H" compiler error. Baidu for a long time also didn't find a way

CodePudding user response:

reference 5 floor zhao4zhong1 reply:
are for reference only:
//1. Create a new console in the VC program, choose to support the MFC (of course, you can also choose not to support the MFC, but will be very troublesome) 
//2. Press CTRL + W v MFC ClassWizard, Add a Class - & gt; From a type library, choose your word's type library
//(for example my word2003, installed in e disk, my path is "e: \ edittools \ Microsoft office \ office11 \ msword olb"),
//choice to end, in the pop-up window, select the let classwizard generated wrapper classes, in this case need
//_Application,
//Documents,
//_Document,
//Range
//the four classes, selected after they click OK
//3. Enter your main function of the CPP file, add a header file reference
//# include "msword. H"//reference just classwizard generated idispatch wrapper class
//4. Add the code
//console_word. CPP: Defines the entry point for the console application.
//

# include "stdafx. H"
# include "console_word. H"
# include "msword. H"
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
The static char THIS_FILE []=__FILE__;
# endif

/////////////////////////////////////////////////////////////////////////////
//The one and only The application object

CWinApp theApp;

Int _tmain (int arg c, TCHAR * argv [], TCHAR * envp [])
{
Int nRetCode=0;

//initialize the MFC and the print and the error on failure
if (! AfxWinInit (: : GetModuleHandle (NULL), NULL, : : GetCommandLine (), 0))
{
//TODO: change the error code to suit your needs
Printf (_T (" Fatal Error: MFC initialization failed! \ n "));
NRetCode=1;
}
The else
{
//TODO: code your application 's behaviors here.
If (CoInitialize (NULL).=S_OK)
{
AfxMessageBox (" initialize COM support library failed!" );
The return - 1;
}

_Application wordApp;
The Documents docs.
_Document doc.
The Range aRange;
COleVariant vTrue (TRUE) (short), vFalse ((short) FALSE), vOpt ((long) DISP_E_PARAMNOTFOUND VT_ERROR);
Cstrings TXT.

WordApp. CreateDispatch (" Word. Application ", NULL);
WordApp. SetVisible (FALSE);
Docs=wordApp. GetDocuments ();
Doc=docs. Open (COleVariant (" c: \ \ new \ \ test. Doc "), vFalse, vTrue, vFalse, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt, vOpt);
ARange=doc. Range (vOpt vOpt);
TXT=aRange the GetText ();
AfxMessageBox (TXT);//for GetText here is plain text word file, you can write in the TXT file
Printf ("] [% s \ n ", TXT. GetBuffer (. TXT GetLength ()));//the newline instead of \ r \ n \ r, so you need to redirect output to a text file as a result,
ARange. ReleaseDispatch ();
Doc. Close (vOpt vOpt, vOpt);
Doc. ReleaseDispatch ();
Docs. ReleaseDispatch ();
WordApp. Quit (vOpt vOpt, vOpt);
WordApp. ReleaseDispatch ();

CoUninitialize ();
}

Return nRetCode;
}



In a 64 - bit Windows:
64 exe and DLL in the directory c: \ Windows \ sys tem32 directory.
32 bit exe and DLL in the directory c: \ Windows \ sys wow64 directory.
So pay attention to:
In win64 system registered under 32-bit ocx DLL to 32 ocx or copy the DLL to the c: \ Windows \ syswow64 \ directory,
And registered to c: \ Windows \ syswow64 \ regsvr32 XXXXXXX ocx or DLL

How do you like to send some irrelevant answer by post

CodePudding user response:

For MFC configuration operation environment of the word

Two ways: 1, the msword. H and msword. CPP added to the project (oneself, resources), will increase a lot of classes, after the completion of the implementation file to add # include "msword. J h,"

. 2, from the type library MSWORD OLB import related classes, specific see: click to open the link (see click open links for some detail explain VS2010 EXECL operation), the actual test will CApplication. Automatically generated a similar h # import "C: \ \ Program Files \ \ Microsoft Office \ \ OFFICE11 \ \ MSWORD OLB" no_namespace commented out, just add the first two lines of code, and then automatically generated for certain. H individual leakage in the void return value of a member function to add the void that is compiled by (don't know why the leakage), and even by some does not need to add additional code, such as clicking links Automating Word 2016 using Visual C + + MFC in Visual Studio 2015 (CodeProject open source project, a detailed), it can be seen that this method is quite complex, a variety of situations, but there are only add need class, more regulated advantages,

In fact, the first way two files are automatically generated after the VC6.0 import the type library, helpless VS2010 and later versions are not make,,,,
  • Related