我一直在努力與C#和PowerPoint,我早前發佈關於如何使用C#更新ppt中的鏈接,如果鏈接設置爲手動,我沒有得到任何迴應,所以我想我會嘗試通過在文件中將鏈接設置爲自動來避免這個問題,然後當C#打開它時,它會更新它們,保存文件,然後將它們分解並保存爲另一個文件名,但這並沒有證明更容易。Break Links PowerPoint 2010
所有我需要知道的是如何打破鏈接。我知道一些VBA並編寫了一段代碼來打破它們,但是當我用C#調用一個RunMacro方法的宏時,它似乎不能與我正在使用的方法一起工作(? - 我是C#的新手,所以我不會不完全理解這是爲什麼,但如果你Google「運行宏觀PowerPoint C#」,你會發現我確信我試圖去做它的方式。)請幫助,我完全失去了。
我的腳本看起來像這樣
Using PowerPoint = Microsoft.Office.Interop.PowerPoint;
public void Main()
{
PowerPoint.Application ppt = new PowerPoint.Application();
PowerPoint.Presentation PRS = ppt.Presentations.Open(@"Filename.pptm",
Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue);
PRS.UpdateLinks();
PRS.Save
//here is where I need to break the links
PRS.SaveAs(@"filename with links broken.pptm",
Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsOpenXMLPresentationMacroEnabled, MsoTriState.msoTrue);
PRS.Close();
ppt.Quit();
}
我試圖打開文件之前設置linkformat爲手動,但這並不影響已經創建的任何形狀,只有程序中創建之後新的。