I have written a simple script to create some PowerPoint sheets based on an Excel dataset. For the original script see Picture1. I noticed that the code becomes very unreadable if you add to many objects to one PowerPoint sheet. That's why I wanted to write a function of this part of the code. One of the things I tried is shown in Picture 2 (I know this code won't work). The problem is that the function doesn't recognize ph_with. Is there anyway to solve this problem?
Thank you!
AddContent <- function(content, label, ...){
ph_with(value = content, location = ph_location_label(ph_label = label))}
AddContent(company_name, Customername)
Error in UseMethod("ph_with", value) : no applicable method for 'ph_with' applied to an object of class "rpptx"
[Picture 1 - original code][1] [1]: https://i.stack.imgur.com/NYCmb.png
[Picture 2 - Function test][2] [2]: https://i.stack.imgur.com/57zaX.png
[Picture 3 - Error message][3] [3]: https://i.stack.imgur.com/TIBgr.png