PPT.ReplaceShapeByGraphic: Replace shape with matching text by graphic

Description Usage Arguments Author(s) See Also Examples

Description

Looks through all shapes of specified type (default rectangles) and finds shapes with matching text pattern. The shape is replaced by an image.

Usage

1
PPT.ReplaceShapeByGraphic(ppt, what, file, shape.type = 1, ...)

Arguments

ppt

The ppt object as used in R2PPT.

what

Text pattern to match against.

file

Path to the graphic file.

shape.type

Shape types in which the text pattern is searched for. By default only rectangles (shape.type = 1) are searched. Other shapes, e.g. rounded rectangles with text, are ignored. To search all shapes use shape.type = NA. The types are documented in the MsoAutoShapeType enumeration in Microsoft's MSDN docu.

...

Arguments passed on to PPT.FitGraphicIntoShape.

Author(s)

Mark Heckmann

See Also

PPT.ReplaceTextByGraphic

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Not run: 

# open PPT template
file <- system.file("template.pptx", package = "R2PPTaddons")
ppt <- PPT.Open(file, method="RDCOMClient")


#### CASE 1: ADD GRAPHIC AT TEXTBOX ####

# add graphic to slides with matching text and remove text. Note that by default
# only text in text boxes is replaced. Text inside rectangles, for example, is
# not touched unless explicitly prompted. Note also that additional arguments
# are passed on to PPT.AddGraphicstoSlide2 to specify the position and size of
# the shape.
what <- "[[tag 1]]"
PPT.ReplaceTextByGraphic(ppt, what, file = "inst/image_1.png", width = .6)

# Note that the text appears twice and the graphic is inserted twice with a warning.
what <- "[[tag 2]]"
PPT.ReplaceTextByGraphic(ppt, what, file = "inst/image_2.png")



#### CASE 2: REPLACE SHAPE BY GRAPHIC ####

# replace rectangle with mathcing text by graphic
what <- "[[tag 1]]"
PPT.ReplaceShapeByGraphic(ppt, what, file = "inst/image_1.png")

# Note  that additional arguments are passed on to PPT.FitGraphicIntoShape and 
# subsequently to PPT.AddGraphicstoSlide2, e.g. to specify the appearance of the image.
what <- "[[tag 2]]"
PPT.ReplaceShapeByGraphic(ppt, what, file = "inst/image_2.png", line.size=1)


## End(Not run)

markheckmann/R2PPTaddons documentation built on June 6, 2019, 11:08 a.m.