public Office文件显示(string str, CE_SystemFileType documentType)
        {
            InitializeComponent();

            try
            {
                oframe.Open(@str);

                oframe.Menubar  = false;
                oframe.Titlebar = false;
                oframe.Toolbars = false;

                this.oframe.ProtectDoc(1, 2, "pwd");

                switch (documentType)
                {
                case CE_SystemFileType.Word:

                    Microsoft.Office.Interop.Word.Document    wordDoc = (Microsoft.Office.Interop.Word.Document)oframe.ActiveDocument;
                    Microsoft.Office.Interop.Word.Application wordApp = wordDoc.Application;
                    break;

                case CE_SystemFileType.Excel:

                    Microsoft.Office.Interop.Excel.Workbook    excelDoc = (Microsoft.Office.Interop.Excel.Workbook)oframe.ActiveDocument;
                    Microsoft.Office.Interop.Excel.Application excelApp = excelDoc.Application;

                    excelApp.OnKey("^x", "");
                    excelApp.OnKey("^c", "");
                    excelApp.OnKey("^v", "");
                    break;

                case CE_SystemFileType.PPT:

                    Microsoft.Office.Interop.PowerPoint._Presentation pptDoc =
                        (Microsoft.Office.Interop.PowerPoint._Presentation)oframe.ActiveDocument;
                    Microsoft.Office.Interop.PowerPoint.Application pptApp = pptDoc.Application;

                    keybd_event((byte)Keys.F5, 0, 0, 0);
                    keybd_event((byte)Keys.F5, 0, 2, 0);

                    break;

                case CE_SystemFileType.PDF:
                    break;

                case CE_SystemFileType.Miss:
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
 private void createSlideFromTemplate()
 {
     //Create a new presentation based on a template.
     objApp         = new Microsoft.Office.Interop.PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet     = objApp.Presentations;
     objPres        = objPresSet.Open(strTemplate,
                                      MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }
示例#3
0
 private void createSlideFromTemplate()
 {
     //Create a new presentation based on a template.
     objApp = new Microsoft.Office.Interop.PowerPoint.Application();
     objApp.Visible = MsoTriState.msoTrue;
     objPresSet = objApp.Presentations;
     objPres = objPresSet.Open(strTemplate,
         MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
     objSlides = objPres.Slides;
 }