[R] using rcom to control Power Point - problem to set a property
Mark Heckmann
mark.heckmann at gmx.de
Mon May 14 19:04:42 CEST 2012
Hi all,
I try to convert the VBA code below to run it from R using rcom and Power Point.
The VBA code creates a shape and will move the handle of the the shape to another position.
This fails using rcom and I do not understand what I am doing wrong...
### VBA ###
ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangularCallout, 144, 144, 200, 200).Select
With ActiveWindow.Selection.ShapeRange
.Adjustments.Item(1) = 0.0942
.Adjustments.Item(2) = 1.7395
End With
### R ###
library(rcom)
## initializing power point program and slide
ppt <- comCreateObject("PowerPoint.Application")
ppt[["visible"]] <- TRUE
pres <- ppt[["Presentations"]]$add()
slide <- pres[["Slides"]]$add(1, 12)
slide$Select()
## adding the ppt autoform (corresponds to the above VBA code). The last lines fail for some reason.
doc <- ppt[["ActivePresentation"]][["Slides"]]$Item(1)
rect <- doc[["Shapes"]]$AddShape(Type=105, Top=144, Left=144, Width=200, Height=200)
rect$Select()
shp <- ppt[["ActiveWindow"]][["Selection"]][["ShapeRange"]]
shp[["Adjustments"]][["Count"]] # there are adjustment items!!
names(comGetObjectInfo(shp[["Adjustments"]])) # there is a function called Item
# now the code below does not work
shp[["Adjustments"]][["Item"]] # does not work
shp[["Adjustments"]]$Item(1) # does not work
shp[["Adjustments"]]$Item(1) <- .9 # does not work -> error
Does someone why this is the case or what I am doing wrong?
Thanks !
Mark
––––––––––––––––––––––––––––––––––––
Mark Heckmann
Blog: www.markheckmann.de
R-Blog: http://ryouready.wordpress.com
More information about the R-help
mailing list