WrdText(txt, fixedfont = TRUE, fontname = NULL, fontsize = NULL,
bold = FALSE, italic = FALSE, col = NULL,
alignment = c("left","right","center"), spaceBefore=0, spaceAfter=0,
lineSpacingRule = wdConst$wdLineSpaceSingle,
appendCR = TRUE, wrd = getOption("lastWord"))
TRUE
.NULL
the fixedfont
will be used, and
if the option does not exist it will be set to Consolas
.NULL
the fixedfontsize
will be used, and if the option does not exist it will be set to 7
.left
, right
, center
GetNewWrd()
or an existing one, created by GetCurrWrd()
.
Default is the last created pointer stored in getOption("lastWord")
.WrdSetFont
, WrdPlot
, GetNewWrd
, GetCurrWrd
# Windows-specific example
# Let's write a story
data(d.diamonds)
# start word
wrd <- GetNewWrd()
WrdCaption("My Word-Story", stylename=wdConst$wdStyleHeading1)
WrdText("This will be the structure of d.diamonds:\n\n", appendCR=FALSE,
fontname="Arial", fontsize=10)
WrdText(capture.output(str(d.diamonds)))
wrd[["Selection"]]$InsertBreak(wdConst$wdPageBreak)
WrdText("Lets insert a table (and this ist written Times)!", fontname="Times",
fontsize=12, appendCR=FALSE, bold=T)
# insert table
wrd[["ActiveDocument"]][["Tables"]]$Add( wrd[["Selection"]][["Range"]],
NumRows=2, NumColumns=2 )
WrdText("First Cell", fontname="Arial", fontsize=10)
wrd[["Selection"]]$MoveRight( Unit=wdConst$wdCell, Count=1 )
WrdText("Second Cell")
wrd[["Selection"]]$MoveRight( Unit=wdConst$wdCell, Count=1 )
wrd[["Selection"]]$MoveRight( Unit=wdConst$wdCharacter, Count=2,
Extend=wdConst$wdExtend )
wrd[["Selection"]][["Cells"]]$Merge()
WrdText("This cell was merged....", fontname="Arial", fontsize=10)
# exit the table range
wrd[["Selection"]]$EndOf( wdConst$wdTable )
wrd[["Selection"]]$MoveRight( wdConst$wdCharacter, 2, 0 )
wrd[["Selection"]]$TypeParagraph()
# let's insert a bookmark
wrd[["ActiveDocument"]][["Bookmarks"]]$Add("myBookmark")
wrd[["Selection"]]$MoveRight( Unit=wdConst$wdCharacter, Count=1 )
WrdText("\n\n", fontname="Arial", fontsize=10)
# set border for a paragraph
BorderBottom <- wrd[["Selection"]][["ParagraphFormat"]][["Borders"]]$Item(-3)
BorderBottom[["LineStyle"]] <- 1
wrd[["Selection"]]$MoveRight( wdConst$wdCharacter, 1, 0 )
WrdText("This paragraph has a Border", fontname="Arial", fontsize=10)
wrd[["Selection"]]$MoveRight( wdConst$wdCharacter, 2, 0 )
WrdText("\n\n", fontname="Arial", fontsize=10)
# insert new landscape section
wrd[["Selection"]]$InsertBreak(wdConst$wdSectionBreakNextPage)
wrd[["Selection"]][["PageSetup"]][["Orientation"]] <- wdConst$wdOrientLandscape
# new text
WrdText("Text in landscape", fontname="Impact", fontsize=20)
wrd[["Selection"]][["PageSetup"]][["Bottommargin"]] <- 4 * 72
wrd[["Selection"]][["PageSetup"]][["Leftmargin"]] <- 4 * 72
# wrd[["Selection"]][["PageSetup"]][["Topmargin"]] <- 4 * 72
# wrd[["Selection"]][["PageSetup"]][["Rightmargin"]] <- 4 * 72
# return to the bookmark
wrd[["Selection"]]$GoTo( wdConst$wdGoToBookmark, 0, 0, "myBookmark")
# and insert text
WrdText("Back again")
# goto end of document
wrd[["Selection"]]$EndKey(wdConst$wdStory)
Run the code above in your browser using DataLab