R: Some Functions to Handle MS-Word Bookmarks

WrdBookmark {DescTools} | R Documentation

## Some Functions to Handle MS-Word Bookmarks

### Description

Accessing bookmarks by name is only possible by browsing the bookmark names. `WrdBookmark` returns a handle to a bookmark by taking its name as argument. `WrdInsertBookmark`, `WrdDeleteBookmark` inserts/deletes a bookmark in a Word document. `WrdGotoBookmark` allows to place the cursor on the bookmark and `WrdUpdateBookmark` replaces the content within the range of the bookmark in a Word document with the given text.

### Usage

    WrdBookmark(name, wrd = DescToolsOptions("lastWord"))

    WrdInsertBookmark(name, wrd = DescToolsOptions("lastWord"))
    WrdDeleteBookmark(name, wrd = DescToolsOptions("lastWord"))

    WrdGoto(name, what = wdConst$wdGoToBookmark, wrd = DescToolsOptions("lastWord"))

    WrdUpdateBookmark(name, text, what = wdConst$wdGoToBookmark,
                      wrd = DescToolsOptions("lastWord"))

### Arguments

`name` | the name of the bookmark.
`text` | the text of the bookmark.
`what` | a word constant, defining the type of object to be used to place the cursor.
`wrd` | the pointer to a word instance. Can be a new one, created by `GetNewWrd()` or an existing one, created by `GetCurrWrd()`. Default is the last created pointer stored in `DescToolsOptions("lastWord")`.

### Details

Bookmarks are useful to build structured documents, which can be updated later.

### Author(s)

Andri Signorell <andri@signorell.net>

### See Also

`WrdFont`, `WrdPlot`, `GetNewWrd`, `GetCurrWrd`

### Examples

    ## Not run:  # we can't get this through the CRAN test - run it with copy/paste to console
    wrd <- GetNewWrd()
    WrdText("a)\n\n\nb)", fontname=WrdGetFont()$name, fontsize=WrdGetFont()$size)
    WrdInsertBookmark("chap_b")
    WrdText("\n\n\nc)\n\n\n", fontname=WrdGetFont()$name, fontsize=WrdGetFont()$size)

    WrdGoto("chap_b")
    WrdUpdateBookmark("chap_b", "Goto chapter B and set text")

    WrdInsertBookmark("mybookmark")
    ToWrd("A longer text\n\n\n")

    # Now returning the bookmark
    bm <- WrdBookmark("mybookmark")

    # get the automatically created name of the bookmark
    bm$name()

    ## End(Not run)

[Package DescTools version 0.99.38 Index]