Title: Simple R Interface to Microsoft PowerPoint using RDCOMClient
Suggests: RDCOMClient
Version: 2.2.0
Author: Wayne Jones <wayne.w.jones@shell.com>
Maintainer: Wayne Jones <wayne.w.jones@shell.com>
Description: Provides a simple set of wrappers to easily use RDCOMClient for generating Microsoft PowerPoint presentations. Warning:this package is soon to be archived from CRAN.
License: GPL-3
Depends: R (≥ 2.3.0)
URL: https://github.com/waynegitshell/R2PPT/
NeedsCompilation: no
Packaged: 2022-04-26 14:03:52 UTC; Wayne.W.Jones
OS_type: windows
Repository: CRAN
Date/Publication: 2022-04-26 14:30:05 UTC

Add a Blank Slide to current PowerPoint presentation

Description

Adds a slide to the current PowerPoint presentation of Microsoft type 'ppLayoutBlank'.

Usage

PPT.AddBlankSlide(ppt)

Arguments

ppt

List of COM objects as initialised by PPT.Init. See example.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init() 
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
rm(myPres)

## End(Not run) 


Adds a R data frame to the current slide

Description

Adds a R data frame to the current slide using the 'AddOLEObject' PowerPoint method.

Usage

PPT.AddDataFrame(ppt, df = stop("Data frame must be specified"), 
size = c(120, 110, 480, 320), row.names = TRUE, col.names = TRUE)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

df

a R dataframe.

size

Optional numeric vector of size 4 (Left,Top,Width,Height) giving the dimensions of the R data frame as it appears in the PowerPoint slide.

row.names

logical; include data frame row names?

col.names

logical; include data frame column names?

Details

The function saves the data frame as a temporary csv file and then inserts this into presentation using the PowerPoint 'AddOLEObject' method. PowerPoint treats this as an embedded Excel file which is convenient for further editing of the data frame.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples

## Not run: 

ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
my.df<-data.frame(weight=weight,group=group)

opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0))
plot(lm(weight ~ group,data=my.df), las = 1)      # Residuals, Fitted, ...
par(opar)


myPres<-PPT.Init(visible=TRUE)
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddGraphicstoSlide(myPres,size= c(200, 10, 500, 500))
myPres<-PPT.AddDataFrame(myPres, df = my.df,row.names=FALSE,size=c(30,100,100,300))
myPres<-PPT.Present(myPres)

### Double click the data frame in PowerPoint to edit further..


## End(Not run)

Adds an R graphics output to the current slide of current PowerPoint presentation

Description

Adds an R graphics output to the current slide of the PowerPoint presentation using the PowerPoint 'AddPicture' method. Graphics output can either be a graphical output file or the current R graphics device as specified by dev.cur.

Usage

PPT.AddGraphicstoSlide(ppt, file = NULL, 
size = c(10, 10, 700, 500), dev.out.type = "jpeg")

Arguments

ppt

List of COM objects as initialised by PPT.Init. See example.

file

Optional filename giving the full file path to R graphics output. See example.

size

Optional numeric vector of size 4 (Left,Top,Width,Height) giving the dimensions of the R graphics in the PowerPoint slide. Defaults to c(10, 10, 700, 500) which covers most of the slide.

dev.out.type

Optional character type of output to use when using current graphics device. Defaults to "jpeg". Ignored if file is specified.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,savePlot

Examples


## Not run: 
myPres<-PPT.Init(visible=TRUE)
myPres<-PPT.AddTitleSlide(myPres,title="How to add R graphics to PowerPoint!")

## Example adding graphic from file
myPres<-PPT.AddBlankSlide(myPres)
jpeg(file="testRplot1.jpeg",quality=100,height=960,width=960)
plot(rnorm(100))
dev.off()
# You must give full file path
myPres<-PPT.AddGraphicstoSlide(myPres,file=paste(getwd(),"testRplot1.jpeg",sep="/"))
unlink(paste(getwd(),"testRplot1.jpeg",sep="/"))
## Example adding graphic from current graphics device
myPres<-PPT.AddBlankSlide(myPres)
windows()
hist(rnorm(100))
myPres<-PPT.AddGraphicstoSlide(myPres,size= c(10, 10, 300, 500))
hist(runif(100))
myPres<-PPT.AddGraphicstoSlide(myPres,size= c(350, 10, 300, 500))


## End(Not run) 


Add a text layout slide to current PowerPoint presentation

Description

Adds a slide to the current PowerPoint presentation of Microsoft type 'ppLayoutText'.

Usage

PPT.AddTextSlide(ppt, title = NULL, title.fontsize = NULL, 
title.font = NULL, text = NULL, text.fontsize = NULL, text.font = NULL)

Arguments

ppt

List of COM objects as initialised by PPT.Init. See example.

title

Optional title text.

title.fontsize

Optional numeric title font size.

title.font

Optional character title font.

text

Optional character text.

text.fontsize

Optional numeric text font size.

text.font

Optional character text font.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init() 
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
rm(myPres)

## End(Not run) 


Add a TitleOnly slide to current PowerPoint presentation

Description

Adds a slide to the current PowerPoint presentation of Microsoft type 'ppLayoutTitleOnly'.

Usage

PPT.AddTitleOnlySlide(ppt, title = NULL, title.fontsize = NULL, title.font = NULL)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

title

Optional title text.

title.fontsize

Optional numeric title font size.

title.font

Optional character title font.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init() 
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
rm(myPres)

## End(Not run) 


Add a title slide to current PowerPoint presentation

Description

Adds a slide to the current PowerPoint presentation of Microsoft type 'ppLayoutTitle'.

Usage

PPT.AddTitleSlide(ppt, title = NULL, subtitle = NULL, title.font = NULL, 
title.fontsize = NULL, subtitle.font = NULL, subtitle.fontsize = NULL)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

title

Optional title text.

subtitle

Optional subtitle text.

title.font

Optional character title font.

title.fontsize

Optional numeric title font size.

subtitle.font

Optional character subtitle font.

subtitle.fontsize

Optional numeric subtitle font size.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init() 
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
rm(myPres)

## End(Not run) 


Applies a Template Design to current PowerPoint presentation

Description

Applies a Template Design to current PowerPoint presentation.

Usage

PPT.ApplyTemplate(ppt,file)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

file

Required filename giving the full file path of PowerPoint Template file. See example.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.Present,PPT.SaveAs,PPT.Close,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init() # or myPres<-PPT.Init(method="RDCOMClient")
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")

#### Must specify full file path to PowerPoint template file. 
#### For PowerPoint 2000 & 2003 should be something like:
myPres<-PPT.ApplyTemplate(myPres,file="C:/Templates/Designs/Carnation.pot")
### For PowerPoint 2007 should be something like:
myPres<-PPT.ApplyTemplate(myPres,file="C:/Templates/1033/ClassicPhotoAlbum.potx")

## End(Not run) 


Close a PowerPoint presentation

Description

Closes a PowerPoint presentation.

Usage

PPT.Close(ppt)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.SaveAs,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
#Example of generating a presentation without making it visible (can be a lot quicker!).
myPres<-PPT.Init(visible=FALSE)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
myPres<-PPT.SaveAs(myPres,file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.Close(myPres)
rm(myPres)

### Open presentation
myPres<-PPT.Open(file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.Present(myPres)

## End(Not run) 


Initialises a PowerPoint presentation

Description

Initialises a PowerPoint presentation by using RDCOMClient.

Usage

PPT.Init(visible=TRUE, method = "RDCOMClient", addPres = TRUE)

Arguments

visible

Optional logical specifying if PowerPoint is visible from initialisation. Useful for debugging. Defaults to TRUE.

method

Choice of underlying COM technology method to implement R2PPT. Legacy function input, always uses RDCOMClient now.

addPres

Add a presentation at initialisation? Defaults to TRUE.

Value

ppt

Invisibly returns an initialised list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init() 
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
rm(myPres)

## End(Not run) 


Open an existing PowerPoint presentation

Description

Opens an existing PowerPoint presentation.

Usage

PPT.Open(file=stop("filename must be specified"),method="RDCOMClient")

Arguments

file

Required filename giving the full file path to existing PowerPoint presentation. See example.

method

Choice of underlying COM technology method to implement R2PPT. Legacy function input, always uses RDCOMClient now.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.SaveAs,PPT.Close,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
#Create and save a presentation

myPres<-PPT.Init(visible=FALSE)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
myPres<-PPT.SaveAs(myPres,file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.Close(myPres)
rm(myPres)

#Open the saved presentation and carry on...

myPres<-PPT.Open(file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.AddTitleOnlySlide(myPres,title="Carry on appending to existing PPT file!")


## End(Not run) 


Run the PowerPoint presentation slideshow

Description

Runs the specified PowerPoint presentation as a full screen slideshow.

Usage

PPT.Present(ppt)

Arguments

ppt

Required list of COM objects as initialised by PPT.Init. See example.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.SaveAs,PPT.Close,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
myPres<-PPT.Init(visible=FALSE)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
myPres<-PPT.SaveAs(myPres,file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.Present(myPres)

## End(Not run) 


Save a PowerPoint presentation to file

Description

Saves a PowerPoint presentation to a specified file.

Usage

PPT.SaveAs(ppt,file)

Arguments

ppt

Required list of objects of class 'COMobject' as initialised by PPT.Init. See example.

file

Required filename to R graphics output. See example.

Value

ppt

Invisibly returns a list of COM objects.

Warning

You must save the returned list of COM objects initialised with PPT.Init to an R object. See the example. No overwrite warning is given.

Author(s)

Wayne Jones wayne.w.jones@shell.com

References

See https://github.com/omegahat/RDCOMClient for more details on RDCOMClient and https://github.com/waynegitshell/R2PPT/ for R2PPT source code.

See Also

PPT.Init,PPT.Close,PPT.AddTitleSlide,PPT.AddTextSlide,
PPT.AddTitleOnlySlide,PPT.Present,PPT.ApplyTemplate,PPT.AddGraphicstoSlide

Examples


## Not run: 
#Example of generating a presentation without making it visible (can be a lot quicker!).
myPres<-PPT.Init(visible=FALSE)
myPres<-PPT.AddBlankSlide(myPres)
myPres<-PPT.AddTitleSlide(myPres,title="Title Slide",subtitle="Subtitle here")
myPres<-PPT.AddTitleOnlySlide(myPres,title="Title Only",title.fontsize=40,title.font="Arial")
myPres<-PPT.AddTextSlide(myPres,title="Text Slide",text="Text1 \rText2 \rText3",text.font="Arial")
myPres<-PPT.SaveAs(myPres,file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.Close(myPres)
rm(myPres)

### Open presentation
myPres<-PPT.Open(file=paste(getwd(),"test R2PPT Pres.ppt",sep="/"))
myPres<-PPT.Present(myPres)

## End(Not run)