Generating a powerpoint presentation with VBA and

2019-08-14 04:02发布

问题:

I have a template presentation on powerpoint. I would like to replace automatically generic placeholders with the value I input in an linked excel worksheet.

I started looking at VBA at the begining of the week, I am not really yet familiar with the syntax, but I am optimistic I will find a way to understand it.

I have put "[ ]" everywhere I want a value input:

the excel sheet present itself like this:

I would like to have some pointers (first, to know if it is indeed possible in powerpoint) to get me started in the right direction.

Does it need to be a PublicSub()? Am I writing the macro on Powerpoint or in Excel?

Can I use a fonction similar to LookupV to get the values to replace the placeholders?

I would imagine something like :

(side question : can I use regex inside of VBA?)

for each "\[.\]" '(or characterString.startsWith("[")
lookup characterString in excel, return column 3
end each

Would this be possible?

Thank you in advance, I really appreciate the help.

回答1:

Found an approximate solution, but simpler than code writing.

  • Open Excel,
  • fill the values, and copy them onto the powerpoint presentation : use the special paste option between the cell (or cells/cell range) you want.
  • Choose the "paste the link" option together with object worksheet Excel, select Ok.

Both files will be linked. You can change the values in Excel, and they will change also in powerpoint. The formating is done on excel.

In order to update all the values in the powerpoint after changing them on excel, powerpoint needs to be re-run, and at the restart of the application, accept the updating box prompt.

I find this simpler than the other solutions.