[英]How to copy specific slides of one PowerPoint presentation to another?
我有下面的代碼,使用該代碼嘗試將一個演示文稿的特定幻燈片復制到另一個演示文稿,但沒有發生,我也沒有收到任何錯誤。
source = ppt.Presentations.Open(filename, MsoTriState.msoTrue,
MsoTriState.msoTrue, MsoTriState.msoTrue);
target = ppt.Presentations.Open(targetname, MsoTriState.msoTrue,
MsoTriState.msoTrue, MsoTriState.msoTrue);
sourceSlideRange = source.Slides.Count;
for (int i = 3; i < sourceSlideRange; i++)
{
source.Slides[i].Copy();
target.Windows[1].Activate();
target.Slides[1].Select();
target.Application.CommandBars.ExecuteMso("PasteSourceFormatting");
}
我的代碼有什么問題? 請提出建議。謝謝
由於我的要求是僅在演示文稿中保留特定的幻燈片,並且張貼的復制代碼無法正常工作,因此我嘗試從演示文稿中刪除不需要的幻燈片,僅保留需要的幻燈片。 下面是解決目的的代碼
Microsoft.Office.Interop.PowerPoint.Application ppt = new Microsoft.Office.Interop.PowerPoint.Application();
ppt.Visible = MsoTriState.msoTrue;
ppt.WindowState = Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMinimized;
source = ppt.Presentations.Open(filename);
target = ppt.Presentations.Open(targetname, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoTrue);
sourceSlideRange = source.Slides.Count;
for (int i = 3; i < sourceSlideRange; i++)
{
source.Slides[i].Delete();
source.Save();
}
source.Close();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.