Điều tôi đang cố gắng thực hiện là điều khiển bản trình bày Powerpoint từ ứng dụng WPF của tôi. Với mã từ câu hỏi này: C# - way to programmatically advance Powerpoint slide show? nó đang hoạt động khá tốt cho các trang trình bày thông thường.Tiến hành Powerpoint Slideshow theo trình tự với các hoạt ảnh nhấp chuột
Nhưng ngay sau khi tôi truy cập trang chiếu có hoạt ảnh do mouseclick kích hoạt, nó không hoạt động như tôi mong đợi. Khi đi đến một slide như vậy, nó sẽ xuất hiện như mong đợi, nhưng khi tôi gọi objPres.SlideShowWindow.View.Next(), nó không làm gì cả, và sau lần nhấp thứ hai hoặc thứ ba, nó sẽ chuyển thẳng đến trang kế tiếp, không hoạt hình.
Điều lạ là: Khi tôi gọi objPres.SlideShowWindow.View.Next() qua Bộ hẹn giờ, nó hoạt động! Ảnh động đang chạy như mong đợi.
Đây là mã tôi có:
Microsoft.Office.Interop.PowerPoint.Application oPPT;
Microsoft.Office.Interop.PowerPoint.Presentations objPresSet;
Microsoft.Office.Interop.PowerPoint.Presentation objPres;
Microsoft.Office.Interop.PowerPoint.SlideShowView oSlideShowView;
Timer slidetest;
private void OpenPPT(object sender, RoutedEventArgs e)
{
//Create an instance of PowerPoint.
oPPT = new Microsoft.Office.Interop.PowerPoint.Application();
// Show PowerPoint to the user.
oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
objPresSet = oPPT.Presentations;
OpenFileDialog Opendlg = new OpenFileDialog();
Opendlg.Filter = "Powerpoint|*.ppt;*.pptx|All files|*.*";
// Open file when user click "Open" button
if (Opendlg.ShowDialog() == true)
{
string pptFilePath = Opendlg.FileName;
//open the presentation
objPres = objPresSet.Open(pptFilePath, MsoTriState.msoFalse,
MsoTriState.msoTrue, MsoTriState.msoTrue);
objPres.SlideShowSettings.ShowPresenterView = MsoTriState.msoFalse;
System.Diagnostics.Debug.WriteLine(objPres.SlideShowSettings.ShowWithAnimation);
objPres.SlideShowSettings.Run();
oSlideShowView = objPres.SlideShowWindow.View;
slidetest = new Timer(4000);
slidetest.AutoReset = false;
slidetest.Elapsed += new ElapsedEventHandler(slidetest_Elapsed);
slidetest.Start();
}
}
void slidetest_Elapsed(object sender, ElapsedEventArgs e)
{
// this works as expected
oSlideShowView.Next();
}
private void OnNextClicked(object sender, RoutedEventArgs e)
{
// this doesn't work, animations aren't shown at all.
oSlideShowView.Next();
}
Tôi chắc chắn đây là một cái gì đó dễ dàng và tôi đang nhìn cái gì đó. Nhưng tôi đập đầu vào lúc này: (
Trong trường hợp này, có thể vấn đề là có hình động hẹn giờ chạy tự động? Nếu vậy, tôi nghi ngờ PPT sẽ không phản hồi oSlideShowView.Next unti nó đã xử lý xong hoạt ảnh –
@ steve-rindsberg no, không có hoạt ảnh định thời nào trong PPT mà tôi đã thử nghiệm.Tôi đã tạo một dự án thử nghiệm và tải nó lên đây: https: // skydrive. live.com/redir.aspx?cid=edd93823761d5c8e&resid=EDD93823761D5C8E!10340&parid=EDD93823761D5C8E!139&authkey=!AMpcxEYSf90vv24, nếu bạn muốn xem qua nó (cũng có ppt kiểm tra trong zip này, chỉ có hai trang trình bày, với một hoạt ảnh nhấp chuột trên trang chiếu đầu tiên). – Malyngo
Tôi không phải là một anh chàng C (sắc nét, phẳng, cộng, trừ) và đang bị đầm lầy vào lúc này. Nếu tôi có thời gian để xem xét, nó sẽ không giúp được gì nhiều. Lấy làm tiếc. –