Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to launch Microsoft Word

How to launch Microsoft Word

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wim Engberts
    wrote on last edited by
    #1

    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

    R H G 3 Replies Last reply
    0
    • W Wim Engberts

      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

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • W Wim Engberts

        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

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        See ShellExecute[^]

        _**


        **_

        WhiteSky


        1 Reply Last reply
        0
        • W Wim Engberts

          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

          G Offline
          G Offline
          georgekjolly
          wrote on last edited by
          #4

          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),

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups