wordReport              package:svViews              R Documentation

_M_a_n_a_g_e _a _r_e_p_o_r_t _i_n _M_i_c_r_o_s_o_f_t _W_o_r_d _f_r_o_m _w_i_t_h_i_n _R

_D_e_s_c_r_i_p_t_i_o_n:

     These various functions allow to control Microsoft Word
     (currently, only through DDE under Windows) to append results to a
     document from within R.

_U_s_a_g_e:

         WordOpen(report = NULL, warn = TRUE)
             WordActivate(async = FALSE)
             WordExit()
             WordGoto(bookmark = NULL)
             WordGotoEnd()
             WordInsertPara()
             WordInsertPageBreak()
             WordInsertText(text)
             WordInsertFile(file, keep.bookmark = FALSE)
             WordInsertPictureFile(file, keep.bookmark = FALSE)
             WordExec(command, type = "DDE", async = FALSE)

_A_r_g_u_m_e_n_t_s:

  report: The path to a Word .doc file to use as a starting basis for
          the report. If 'report == NULL' (by default), Word is just
          opened with a new empty document, if it was not already
          running. 

    warn: Should the function issue a warning if it cannot find or
          start Microsoft Word? 

   async: Would the command run asynchroneously (returns immediatelly,
          before the command is fully processed by Word), on not (by
          default). 

bookmark: A bookmark in the current Word document to select. If
          'bookmark = NULL' (by default), the GoTo dialog box of Word
          is opened, and you have an opportunity to navigate to a given
          place in your Word document before continuing (to indicate
          where to place the next piece of report in your file). If you
          specify 'bookmark = ""', the insertion point is moved to the
          beginning of the current document. 

    text: A text to insert in the Word document. Note that you can use
          \n or \v for forced line breaks insider a paragraph, \r for
          going to the next paragraph, \f for inserting a page break
          and \t for a tabulation. 

    file: The path to a file containing data or an image to insert in
          the current Word document. All formats supported by Microsoft
          Word are accepted and automatically converted (e.g., HTML,
          RTF, ... and for images, BMP, TIFF, GIF, WMF, EMF, ...) 

keep.bookmark: A flag to indicate that we want to keep the currently
          selected bookmark. When using 'WordInsertFile()' or
          'WordInsertPictureFile()' with this option set to 'FALSE',
          any selected bookmark is deleted. With this option set to
          'TRUE', the bookmark is preserved, but note that it requires
          a non-empty selection in the active Word document! 

 command: A command to execute in Word 

    type: The type of communication to use with Word. Currently, only
          DDE is valid. 

_D_e_t_a_i_l_s:

     These are various functions to control Microsoft Word: open it,
     open or activate a given document, insert text, pictures, or other
     items, and select a position in the document. All functions return
     invisibly 'TRUE' in case of success and 'FALSE' otherwise. Note
     that 'WordGoto(\"my bookmark\")' will fail if there is no bookmark
     called \"my bookmark\" in the active document... and R will not be
     advised of the error, that is, the function still returns 'TRUE'
     in this case! This is because there is no feedback mechanism from
     Word to R implemented yet! 'WordExec()' is the low-level function
     that allows to pass directly WordBasic commands to Word. It is not
     normally used directly, but it can be useful for commands not
     included in the other functions. Look at the WordBasic help and
     the code of the other functions to learn how you should enter
     these commands...

_V_a_l_u_e:

     Returns invisibly 'TRUE' for 'report()' and the path to the
     created PNG file for 'reportGraph()'.

_A_u_t_h_o_r(_s):

     Philippe Grosjean <phgrosjean@sciviews.org>

_S_e_e _A_l_s_o:

     'report'

_E_x_a_m_p_l_e_s:

         ## Not run: 
             WordOpen()      # Open Miscrosoft Word with a new empty document (or activate current doc)
                     WordGotoEnd() # Move insertion point to the end of that document
                     # Insert some text in it
                     WordInsertText("Some \ttext...\nOther text after line feed in same para\rOther para\fOther page")
                     # Insert a new paragraph
                     WordInsertPara()

                     # Open an existing Word document (it must exist there, of course!)
                     WordOpen("c:/temp/test.doc")
                     WordGoto() # Display the GoTo dialog box in Word, and allow to navigate to a given place or bookmark manually
                     WordInsertPictureFile("c:/temp/test.emf")       # Insert a picture there (he file must exist, of course!)
                     WordGoto("my bookmark") # Go to the "my bookmark" bookmark (it must exist, otherwise an error is issued in Word!)
                     WordInsertFile("c:/temp/test.html", "testit") # Insert a piece of HTML there (the file must exist, of course!)
                     WordExit()      # Close word, possibly prompting to save all unsaved documents before.
         ## End(Not run)

