简体   繁体   English

使用VBA和Excel生成PowerPoint演示文稿

[英]Generating a powerpoint presentation with VBA and Excel

I have a template presentation on powerpoint. 我在PowerPoint上有一个模板演示文稿。 I would like to replace automatically generic placeholders with the value I input in an linked excel worksheet. 我想用在链接的excel工作表中输入的值自动替换通用占位符。

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. 我从本周开始就开始研究VBA,虽然我还不太熟悉语法,但是我很乐观地会找到一种理解它的方法。

I have put "[ ]" everywhere I want a value input: 我在需要输入值的所有地方都放置了“ []”: 在此处输入图片说明

the excel sheet present itself like this: Excel工作表呈现如下: 在此处输入图片说明

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. 我想提出一些指导(首先要知道在Powerpoint中是否确实有可能),以使我朝正确的方向入手。

Does it need to be a PublicSub()? 是否需要是PublicSub()? Am I writing the macro on Powerpoint or in Excel? 我是在Powerpoint上还是在Excel中编写宏?

Can I use a fonction similar to LookupV to get the values to replace the placeholders? 我可以使用类似于LookupV的功能来获取替换占位符的值吗?

I would imagine something like : 我会想象这样的事情:

(side question : can I use regex inside of VBA?) (旁边的问题:我可以在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. 在此先感谢您,非常感谢您的帮助。

Found an approximate solution, but simpler than code writing. 找到了一个近似的解决方案,但比编写代码简单。

  • Open Excel, 打开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. 填充值,然后将其复制到PowerPoint演示文稿中:在所需的单元格(或单元格/单元格范围)之间使用特殊的粘贴选项。
  • Choose the "paste the link" option together with object worksheet Excel, select Ok. 选择“粘贴链接”选项以及对象工作表Excel,选择“确定”。

Both files will be linked. 这两个文件将被链接。 You can change the values in Excel, and they will change also in powerpoint. 您可以在Excel中更改值,它们在PowerPoint中也将更改。 The formating is done on excel. 格式化是在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. 为了在excel上更改Powerpoint后更新其所有值,需要重新运行powerpoint,并在应用程序重新启动时接受更新框提示。

I find this simpler than the other solutions. 我发现这比其他解决方案更简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM