How to launch Microsoft Word
-
Hi, I am writing an application that generates documents and I wqould like to open them in Microsoft Word automatically. Does anyone have an idea how to launch Word with the relevant document from within my application? Thanks in advance, William
-
Hi, I am writing an application that generates documents and I wqould like to open them in Microsoft Word automatically. Does anyone have an idea how to launch Word with the relevant document from within my application? Thanks in advance, William
This may help: http://www.codeproject.com/cpp/cppforumfaq.asp#cpp_runapp[^] Use the ShellExecute version if your file extension is already associated with Word.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
-
Hi, I am writing an application that generates documents and I wqould like to open them in Microsoft Word automatically. Does anyone have an idea how to launch Word with the relevant document from within my application? Thanks in advance, William
-
Hi, I am writing an application that generates documents and I wqould like to open them in Microsoft Word automatically. Does anyone have an idea how to launch Word with the relevant document from within my application? Thanks in advance, William
Hi try this, may help u http://support.microsoft.com/kb/178749/E-US/ then use this code in ur programme BOOL CLastApp::InitInstance() { if(!AfxOleInit()) // Your addition starts here { AfxMessageBox("Could not initialize COM dll"); return FALSE; } else { //AfxMessageBox("Inint"); } _Application app; // app is the Excel _Application object if(!app.CreateDispatch("Word.Application")) { AfxMessageBox("Couldn't start Excel."); } else { app.SetVisible(TRUE); } COleVariant covTrue((short)TRUE),covFalse((short)FALSE),covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR),covFormat( short(7)); COleVariant m_Long((long)DISP_E_PARAMNOTFOUND, VT_ERROR); AfxEnableControlContainer(); Documents docs = app.GetDocuments(); unsigned long int i = 1; CFileFind finder; CString file_name; CString path; BOOL bWorking = finder.FindFile("d:/george/*.doc"); while(bWorking){ bWorking = finder.FindNextFile(); file_name = finder.GetFileName(); path = "D:\\george\\"+ file_name; //AfxMessageBox(path); _Document doc = docs.Open( COleVariant(path), covTrue, // Confirm Conversion. covTrue, // ReadOnly. covFalse, // AddToRecentFiles. covOptional, // PasswordDocument. covOptional, // PasswordTemplate. covFalse, // Revert. covOptional, // WritePasswordDocument. covOptional, // WritePasswordTemplate. covTrue, covTrue, covOptional, covOptional, covOptional, covOptional); /*VARIANT* FileName, VARIANT* FileFormat, VARIANT* LockComments, VARIANT* Password, VARIANT* AddToRecentFiles, VARIANT* WritePassword, VARIANT* ReadOnlyRecommended, VARIANT* EmbedTrueTypeFonts, VARIANT* SaveNativePictureFormat, VARIANT* SaveFormsData, VARIANT* SaveAsAOCELetter, VARIANT* Encoding, VARIANT* InsertLineBreaks, VARIANT* AllowSubstitutions, VARIANT* LineEnding, VARIANT* AddBiDiMarks)*/ /*doc.SaveAs(COleVariant(path), covFormat,covOptional,covOptional, covOptional,covOptional,covFalse,covOptional, covTrue,covFalse,covOptional, covOptional,covTrue,covOptional,covOptional,covOptional);*/ file_name.Format("%lu",i); path = "D:\\work\\"+file_name+".txt"; //AfxMessageBox(path); doc.SaveAs( COleVariant(path),