확인. 여기 내 질문에 대한 나의 최종 대답이있다. 차트가 편집되지 않도록 유지하면서 슬라이드를 완벽하게 복제 할 수있는 완성 된 코드를 보여줍니다. 즉, .png로 바꾸면됩니다.
이렇게하면 자리 표시 자의 이전 문제가 해결됩니다.
바라건대이 코드 중 일부는 제가 인터넷처럼 누군가를 트래킹하는 데 도움이되기를 바랍니다.
//Open the slides presentation
var pres = _application.Presentations.Open2007(item.PresentationPath,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoFalse);
//For slide ranges
foreach (var i in range)
{
//Get the old slide
var oldSlide = pres.Slides[i];
oldSlide.Copy();
//Paste the slide into the new presentation
var newSlide = newPresentation.Slides.Paste(totalSlides + 1);
newSlide.Design = oldSlide.Design;
newSlide.ColorScheme = oldSlide.ColorScheme;
/* The shapes haven't retained their content because we are not in slide...
view because there is no window. */
//Delete all the shapes that were just pasted in because of the slide paste.
for (int k = newSlide.Shapes.Count; k > 0; k--)
{
newSlide.Shapes[k].Delete();
}
//Put in our shapes
//Loop forwards, because we arn't editing the list and forward is required to
//maintain the zorder we want on some slides.
for (int j = 1; j <= oldSlide.Shapes.Count; j++)
{
var oldShape = oldSlide.Shapes[j];
oldShape.Copy();
//Paste Put it where it should be on the page
/* This is a special case where the client have put textboxes in the
Powerpoint and rotated throwing off the position, so we need treat as rotated
shapes to make it right. */
if (oldShape.HasTextFrame == MsoTriState.msoTrue && Math.Abs(oldShape.Rotation) > 0)
{
//Paste as a shape because it's a more complex object
//set ALL THE PROPERTIES just in case.
var newShape = newSlide.Shapes.PasteSpecial(PpPasteDataType.ppPasteShape);
newShape.Rotation = oldShape.Rotation;
newShape.Top = oldShape.Top;
newShape.Left = oldShape.Left;
newShape.TextFrame.Orientation = oldShape.TextFrame.Orientation;
newShape.TextFrame.WordWrap = oldShape.TextFrame.WordWrap;
newShape.TextFrame.VerticalAnchor = oldShape.TextFrame.VerticalAnchor;
}
else // Act normally
{
//Paste the old shape into the new slide as an image to ENSURE FORMATTING
var newShape = newSlide.Shapes.PasteSpecial(PpPasteDataType.ppPastePNG);
newShape.Top = oldShape.Top;
newShape.Left = oldShape.Left;
}
}
totalSlides += ((item.EndIndex - item.StartIndex) + 1);
pres.Close();
}
새 프레젠테이션을 컴파일 한 후에는 모든 자리 표시자를 삭제해야합니다.
//Loop through all slides
foreach (Slide exportSlide in newPresentation.Slides)
{
//Delete the placeholders
for (int i = exportSlide.Shapes.Placeholders.Count; i > 0; i--)
{
exportSlide.Shapes.Placeholders[i].Delete();
}
}
차트를 그룹화하지 않으면 데이터를 토스하고 PPT에서 표시하는 차트의 EMF/WMF 그림을 남깁니다. –
C#으로이 작업을 수행하는 방법에 대한 아이디어가 있습니까? 나의 현재 아이디어는 슬라이드를 이미지로 내 보낸 다음 어떻게 든 슬라이드로 다시 가져 오는 것입니다. – Callum
C#을 사용하지 않아도되지만 VBA에서 번역하는 것이 상대적으로 쉽고 아래/위의 새로운 대답에 나와 있습니다. –