Home > Back-end >  VS open doc documents with C language, and for each font types
VS open doc documents with C language, and for each font types

Time:09-20

VS open doc documents with c + + language, and you a great god through passing glance at

CodePudding user response:

Now I'm doing this thing, now there are two ways one is forced to open the second is to use computer in msword opens the file

Give you the code
A
ShellExecute (NULL, _T (" open "), _T (" explorer. Exe "), filePath, NULL, SW_SHOWNORMAL);//open the path to the file to you to open the file address
2
MFC under
If (CoInitialize (NULL).=0)
{
AfxMessageBox (_T (" initialize COM support library failed!" ));
exit(1);
}


CApplication oWord;//msword olb office in your computer under
CDocuments oDocs;
CDocument0 Doc.
CRange aRange;
CSelection sel.
CFont0 font;
CWords word;

Cstrings st2, st3, st4 st5;

//Create an instance of a Word.
if (! OWord. CreateDispatch (_T (" Word. Application "))) {
AfxMessageBox (_T (the Word "failed to start!" ));
}
The else
{

//set the visible
OWord. Put_Visible (VARIANT_TRUE);
//Add a new document.
ODocs=oWord. Get_Documents ();

Cstrings FileName=_T (" E: \ \ project \ \ 1. Doc ");//path
COleVariant vFileName (FileName);
COleVariant vTrue (TRUE) (short);
COleVariant vFalse (FALSE) (short);
COleVariant vOptional ((long) DISP_E_PARAMNOTFOUND VT_ERROR);

ODocs. Open (vFileName, vTrue vFalse, vFalse, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional, vOptional);
  • Related