home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / WINWRD.PRG < prev    next >
Text File  |  1995-10-12  |  1KB  |  68 lines

  1.  
  2. #include "windows.ch"
  3.  
  4.  
  5. function main_wword()
  6. local    hWnd := WinSetup("test", "test")
  7. local    hServer
  8.  
  9. hServer = DDEStart(hWnd, "WINWORD", "System")
  10.  
  11. if empty(hServer) .and. !RunWinWord()
  12.     quit
  13. endif
  14.  
  15. hServer = DDEStart(hWnd, "WINWORD", "System")
  16.  
  17. if empty(hServer)
  18.     quit
  19. endif
  20.  
  21. // NOTE: *** This assumes the file to print is TEST.DOC ***
  22. //
  23. // open, print & close - note the embedded quotes (")
  24. DDEExecute(hServer, hWnd, '[FileOpen("test.doc")][FilePrint()][FileExit(2)]',;
  25.            .f.)
  26.  
  27. DDEStop(hServer, hWnd)
  28.  
  29. return 0
  30.  
  31.  
  32. function RunWinWord()        // --> .t. if started ok
  33. local    hModule, cDir, cFile, cWordDir, cDoc
  34.  
  35. // try a simple RUN
  36. hModule = WinExec("WINWORD.EXE", SW_SHOWMINNOACTIVE)
  37.  
  38. if hModule >= 32
  39.     return .t.
  40. endif
  41.  
  42. // didn't run, start hunting for it...
  43.  
  44. // try WINWORD6.INI, if it exists
  45. cDir = GetWindowsDirectory()
  46. if file(cFile := (cDir + "\WINWORD6.INI"))
  47.     cWordDir = GetPvProfString("Microsoft Word", "PROGRAMDIR", "", cFile)
  48.     if !empty(cWordDir)
  49.         hModule = WinExec(cWordDir + "\WINWORD.EXE", SW_SHOWMINNOACTIVE)
  50.         if hModule >= 32
  51.             return .t.
  52.         endif
  53.     endif
  54. endif
  55.  
  56. // try [Extensions] in WIN.INI
  57. cDoc = GetProfString("Extensions", "doc", "")
  58. cDoc = left(cDoc + " ", at(" ", cDoc) - 1)    // remove " ^.doc" if there
  59. if !empty(cDoc)
  60.     hModule = WinExec(cDoc, SW_SHOWMINNOACTIVE)
  61.     if hModule >= 32
  62.         return .t.
  63.     endif
  64. endif
  65.  
  66. return .f.    // failed
  67.  
  68.