• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 自動運行的MS-OFFICE應用程序

    發表于:2007-07-14來源:作者:點擊數: 標簽:
    這個指南幫助你學習自動運行的基
    這個指南幫助你學習自動運行的基礎。用這個代碼,你可以在你的應用程序中控制POWERPOINT。

    你可以程序化的打開POWERPOINT,打開任何展示,到你想觀看的幻燈片,運行幻燈片放映等等。

    通過下面給出的同樣的步驟,你可以自動運行WORD,EXCEL,或者任何MS-OFFICE應用程序。

    (1)       創建一個基于應用程序的對話框,在appwizard的第三步,選擇AUTOMATION復選框。

    (2)       為START , RUN, CLOSE, FIRST SLIDE, LAST SLIDE, PREVIOUS SLIDE和NEXT SLIDE函數創建按鈕,從而使用下列函數。

    (3)       在你的應用程序的InitInstance添加下列語句:

           // Initialize OLE libraries
             if (!AfxOleInit())
             {
                      AfxMessageBox("Failed to initialize OLE");
                      return FALSE;
             }

    (4)       在你的對話框類中,打開classwizard , 選擇AUTOMATION標簽,選擇
    ADD CLASS --> FROM A TYPE LIBRARY.,然后從C:\Program Files\Microsoft Office\Office\中選擇msppt8.olb。

    (5)       在你的對話框的頭文件中,添加語句:

    #include "msppt8.h"
    (6)在你的對話框頭文件中添加下列變量:
         _Application app;  // app is the Powerpoint _Application object



             
             Presentations Presentations;
             _Presentation Presentation;

             SlideShowView View;

             SlideShowWindow SlideShowWindow;
             SlideShowSettings slideshow;
             Slides slides;     
            _Slide slide;
            現在讓我們到POWERPOINT應用程序函數。
    (6)       要啟動POWERPOINT,你必須在START函數中寫出下列代碼:
           void CPowerPntDlg::OnBtnStart()
             {
                   // Start Powerpoint and get Application object...
                   if(!app.CreateDispatch("Powerpoint.Application"))
                   {
                           AfxMessageBox("Couldn't start Powerpoint.");
                       }
                   else
                   {
                    // Make Powerpoint Visible and display a message
                    app.SetVisible(TRUE);
                    TRACE("Powerpoint is Running!");
                       }
             }

    (7)       在硬盤中打開一個展示,在Open按鈕函數呼叫中添加代碼:
             void CPowerPntDlg::OnBtnOpen()
             {
                      static char BASED_CODE szFilter[] = "Powerpoint Files (*.ppt)|*.ppt||";
                      CFileDialog FileDlg(TRUE,"PPT",NULL,OFN_FILEMUSTEXIST|OFN_NONETWORKBUTTON|OFN_PATHMUSTEXIST,szFilter);
                      FileDlg.DoModal();

                    // To get the selected file's path and name
                      CString strFileName;
                      strFileName = FileDlg.GetPathName();

                      if(!strFileName.IsEmpty())
                      {
                           Presentations = app.GetPresentations();
                           Presentation = Presentations.Open(strFileName,0,0,1);
                      }
             }
    (8)       為關閉POWERPOINT,在CLOSE按鈕函數呼叫中添加代碼:
             void CPowerPntDlg::OnBtnClose()
             {
                 if (CanExit())
                      app.Quit();
             }
            在步驟7,8,9中的函數是你需要知道應用程序的基本處理。
            現在我們有了運行的POWERPOINT且有了準備,我們需要用它做一些事情像運行幻燈片放映和執行其他行為。
            現在讓我們運行幻燈片放映。
    (9)       為運行幻燈片放映,在RUN按鈕函數呼叫中添加代碼:
           void CPowerPntDlg::OnBtnRun()
             {
                      Presentations = app.GetActivePresentation();
                      slides = Presentation.GetSlides();
                      // Show the first slide of the presentation
                      slide = slides.Item(COleVariant((long)1));

                      //Run the show
                      slideshow = Presentation.GetSlideShowSettings();
                      slideshow.Run();
             }
    (10)   有時,你可能想從第一張幻燈片中啟動全部。要到第一張幻燈片你可以使用這些代碼:
             void CPowerPntDlg::OnBtnFirst()
             {
                      Presentation = app.GetActivePresentation();
                      SlideShowWindow = Presentation.GetSlideShowWindow();
                      View = SlideShowWindow.GetView();
                      View.First();
             }

    (11)   相似地,到最后一張幻燈片:
           void CPowerPntDlg::OnBtnLast()
             {
                      Presentation = app.GetActivePresentation();
                      SlideShowWindow = Presentation.GetSlideShowWindow();
                      View = SlideShowWindow.GetView();
                      View.Last();
             }
    (12)   既然你有了運行的幻燈片放映,你顯然會在一些時間點上回到上一張幻燈片。要這樣做,使用下列代碼:
             void CPowerPntDlg::OnBtnPrevious()
             {
                      Presentation = app.GetActivePresentation();
                      SlideShowWindow = Presentation.GetSlideShowWindow();
                      View = SlideShowWindow.GetView();
                      View.Previous();
             }

    (13)   現在有興趣到下一張幻燈片?在這種情況下,這個函數會幫助你:
           void CPowerPntDlg::OnBtnNext()
             {
                      Presentation = app.GetActivePresentation();
                      SlideShowWindow = Presentation.GetSlideShowWindow();
                      View = SlideShowWindow.GetView();
                      View.Next();
             }
    這就是了,伙計。檢查出其他轉變,動畫制作等的可用函數。你可以用你特有的方式進行。
    這是基本框架,你可以看出它處理POWERPOINT是多么容易。用在WORD,EXCEL和其它MS-OFFICE上也是一會事。祝好運和快樂!

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>