简体   繁体   English

VBA Excel图表到PowerPoint-将文件另存为多个输出

[英]VBA Excel Chart to powerpoint - saving file as multiple outputs

I have a template in excel, and a powerpoint template. 我在excel中有一个模板,还有一个PowerPoint模板。

in the powerpoint template I have several charts linked to the excel template. 在PowerPoint模板中,我有几个与excel模板链接的图表。

I want to make a loop that changes something in excel, so that the chart updates, "saveas" for both the excel and powerpoint file, so I have eg. 我想做一个循环,以更改excel中的某些内容,以便图表更新为excel和powerpoint文件的“ saveas”,所以我有例如。 100 different excel files and 100 different powerpoint files, all build on the templates. 模板均构建了100个不同的excel文件和100个不同的powerpoint文件。 I want to be able to manually alter some data in those 100 excelfiles, with the link to powerpoint still intact, so they are updated too if needed. 我希望能够手动更改那100个excelfile中的一些数据,而指向powerpoint的链接仍然完好无损,因此如果需要,它们也将进行更新。

however, when I open the powerpoint templates, right click on a chart and select "edit data", then the chart is still linked to the excel template, not the saveas version of the excel file? 但是,当我打开PowerPoint模板时,右键单击图表并选择“编辑数据”,那么该图表仍链接到excel模板,而不是excel文件的saveas版本吗?

how do I change the link of a chart in powerpoint, to a different excel filename? 如何将Powerpoint中图表的链接更改为其他Excel文件名? the structure in the two excel files are identical. 两个Excel文件中的结构相同。

the chart is created in excel and copy/pasted as "keep source formatting and chain data" (translated from danish) 该图表在excel中创建,并复制/粘贴为“保留源格式和链数据”(从丹麦语翻译而来)

any help would be greatly appreciated. 任何帮助将不胜感激。

I have also tried a solution where the copy/paste is done via vba into an empty powerpoint template, but that is more time consuming, and powerpoint often crashes. 我还尝试了一种解决方案,其中通过vba将复制/粘贴复制到一个空的Powerpoint模板中,但这比较耗时,并且Powerpoint经常崩溃。

Assuming you have a reference to the shape represented by the linked chart in oSh, this will show you the link: 假设您对由oSh中的链接图表表示的形状有引用,则将向您显示链接:

Debug.Print oSh.LinkFormat.SourceFullName

And this will change it to some other file: 并将其更改为其他文件:

oSh.LinkFormat.SourceFullName = "c:\some\path\yourfile.xls"

Most likely there will also be a !chartname or the like after yourfile.xls ... you'll need to include that. 很可能在yourfile.xls之后还会有!chartname之类的名称……您需要包括该名称。

And save the Excel files first, THEN change the link in the PPT to point to them. 并首先保存Excel文件,然后更改PPT中的链接以指向它们。 If you change the link to point to a non-existent file, PPT won't throw any errors; 如果将链接更改为指向不存在的文件,则PPT不会引发任何错误; it'll simply leave the link unchanged. 只需保持链接不变即可。

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

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