Ejemplo n.º 1
0
        public void addImage(string path, string transform)
        {
            Microsoft.Office.Interop.PowerPoint.Presentation p = this.Application.ActivePresentation;
            int numberOfSlides = p.Slides.Count;

            numberOfSlides++;

            p.Slides.Add(numberOfSlides, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutObjectAndText);
            int numShapes = p.Slides[numberOfSlides].Shapes.Count;

            p.Slides[numberOfSlides].Shapes.AddPicture(path, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 0);
            Microsoft.Office.Interop.PowerPoint.Shape s = p.Slides[numberOfSlides].Shapes[2]; // Shape 2 is the image, 1 the title and 3 the items list to the right
            s.AlternativeText = transform;
            try
            {
                var           codeModule = p.VBProject.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule);
                StringBuilder moduleCode = new StringBuilder();
                moduleCode.AppendLine("Sub ShowInfo(s AS String)");
                moduleCode.AppendLine("\t" + @"Msgbox s");
                moduleCode.AppendLine("End Sub");
                codeModule.CodeModule.AddFromString(moduleCode.ToString());
                s.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].Action = Microsoft.Office.Interop.PowerPoint.PpActionType.ppActionRunMacro;
                s.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].Run    = "ShowInfo(\"" + transform + "\")";
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 「名前を付けて保存」前イベント
 /// </summary>
 /// <param name="Pres">Presentation情報</param>
 /// <param name="Cancel">キャンセルフラグ</param>
 private void ApplicationPresentationBeforeSave(Microsoft.Office.Interop.PowerPoint.Presentation Pres, ref bool Cancel)
 {
     if (Pres == this.Application.ActivePresentation)
     {
         PresentationSave(Pres, ref Cancel, true);
     }
 }
 /// <summary>
 /// Fired when active presentation is closed
 /// </summary>
 /// <param name="Pres"></param>
 void Application_PresentationClose(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
 {
     System.Diagnostics.Debug.Print("Event: PresentationClose {0}", Pres.FullName);
     if (m_AlfrescoPane != null)
     {
         m_AlfrescoPane.OnDocumentBeforeClose();
     }
 }
 /// <summary>
 /// Fired when active presentation gets focus
 /// </summary>
 /// <param name="Pres"></param>
 /// <param name="Wn"></param>
 void Application_WindowActivate(Microsoft.Office.Interop.PowerPoint.Presentation Pres, Microsoft.Office.Interop.PowerPoint.DocumentWindow Wn)
 {
     System.Diagnostics.Debug.Print("Event: WindowActivate {0}", Pres.FullName);
     if (m_AlfrescoPane != null)
     {
         m_AlfrescoPane.OnDocumentChanged();
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 保存処理本体
        /// </summary>
        /// <param name="Pres">Presentation情報</param>
        /// <param name="Cancel">保存フラグ</param>
        /// <param name="SaveAsUI">キャンセルフラグ</param>
        public void PresentationSave(Microsoft.Office.Interop.PowerPoint.Presentation Pres, ref bool Cancel, bool SaveAsUI)
        {
            // PowerPoint画面が表示されていない場合は設定画面を表示しない
            if (this.Application.Visible == Microsoft.Office.Core.MsoTriState.msoFalse)
            {
                return;
            }

            // プロパティ情報取得
            PowerPointAddInSAB.SettingForm frmSet = new PowerPointAddInSAB.SettingForm();
            frmSet.propPres = Pres;

            // 共通設定エラー時処理
            if (frmSet.commonFileReadCompleted == false)
            {
                return;
            }

            // スライド数が0のときは登録不要
            if (frmSet.GetSlideCount() <= 0)
            {
                return;
            }

            string strFilePropertySecrecyLevel = string.Empty; // ファイルプロパティ情報 機密区分
            string strFilePropertyClassNo      = string.Empty; // ファイルプロパティ情報 事業所コード
            string strFilePropertyOfficeCode   = string.Empty; // ファイルプロパティ情報 事業所コード

            // プロパティのタグを取得
            frmSet.GetDocumentProperty(ref strFilePropertySecrecyLevel, ref strFilePropertyClassNo, ref strFilePropertyOfficeCode); // プロパティ情報取得

            // プロパティにSAB情報は未設定の場合は設定画面を表示
            if (frmSet.IsSecrecyInfoRegistered() == false)
            {
                // 必須登録モードON
                frmSet.MustRegistMode = true;

                frmSet.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                frmSet.ShowDialog();
            }
            else
            {
                // ファイルの事業所コードと設定値の事業所コードを比較
                if (strFilePropertyOfficeCode == frmSet.clsCommonSettting.strOfficeCode)
                {
                    // プロパティに情報を書込み
                    frmSet.SetDocumentProperty(strFilePropertySecrecyLevel);
                }
                else
                {
                    // 修正を押下された場合は、設定画面を表示する
                    frmSet.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                    frmSet.ShowDialog();
                }
            }
        }
Ejemplo n.º 6
0
        //Loads exposition id for current presentation
        void ThisAddIn_AfterPresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
        {
            if (!userId.Equals(0))
            {
                this.loadExpositionId(Pres.Name);

                //Resets the DB exposition index
                if (!this.expositionId.Equals(0))
                {
                    String slideId = "1";
                    this.updateSlide(slideId);
                }
            }
        }
Ejemplo n.º 7
0
        public static void EnsurePowerPointIsRunning(bool blnAddPresentation, bool blnAddSlide)
        {
            string strName = null;
            //
            //Try accessing the name property. If it causes an exception then
            //start a new instance of PowerPoint
            try
            {
                strName = objPPT.Name;
            }
            catch (Exception)
            {

                StartPowerPoint();
            }
            //
            //blnAddPresentation is used to ensure there is a presentation loaded
            if (blnAddPresentation == true)
            {
                try
                {
                    strName = objPres.Name;
                }
                catch (Exception)
                {
                    objPres = objPPT.Presentations.Add(MsoTriState.msoTrue);
                }
            }
            //
            //BlnAddSlide is used to ensure there is at least one slide in the
            //presentation
            if (blnAddSlide)
            {
                try
                {
                    strName = objPres.Slides[1].Name;
                }
                catch (Exception)
                {
                    Microsoft.Office.Interop.PowerPoint.Slide objSlide = null;
                    Microsoft.Office.Interop.PowerPoint.CustomLayout objCustomLayout = null;
                    objCustomLayout = objPres.SlideMaster.CustomLayouts[1];
                    objSlide = objPres.Slides.AddSlide(1, objCustomLayout);
                    objSlide.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText;
                    objCustomLayout = null;
                    objSlide = null;
                }
            }
        }
Ejemplo n.º 8
0
        public static void EnsurePowerPointIsRunning(bool blnAddPresentation, bool blnAddSlide)
        {
            string strName = null;

            //
            //Try accessing the name property. If it causes an exception then
            //start a new instance of PowerPoint
            try
            {
                strName = objPPT.Name;
            }
            catch (Exception)
            {
                StartPowerPoint();
            }
            //
            //blnAddPresentation is used to ensure there is a presentation loaded
            if (blnAddPresentation == true)
            {
                try
                {
                    strName = objPres.Name;
                }
                catch (Exception)
                {
                    objPres = objPPT.Presentations.Add(MsoTriState.msoTrue);
                }
            }
            //
            //BlnAddSlide is used to ensure there is at least one slide in the
            //presentation
            if (blnAddSlide)
            {
                try
                {
                    strName = objPres.Slides[1].Name;
                }
                catch (Exception)
                {
                    Microsoft.Office.Interop.PowerPoint.Slide        objSlide        = null;
                    Microsoft.Office.Interop.PowerPoint.CustomLayout objCustomLayout = null;
                    objCustomLayout = objPres.SlideMaster.CustomLayouts[1];
                    objSlide        = objPres.Slides.AddSlide(1, objCustomLayout);
                    objSlide.Layout = Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText;
                    objCustomLayout = null;
                    objSlide        = null;
                }
            }
        }
Ejemplo n.º 9
0
        private void ActivateDocument(Microsoft.Office.Interop.PowerPoint.Presentation presentation)
        {
            OfficeDocument officeDocument = new PowerPoint2007OfficeDocument(presentation);

            if (officeDocument.IsPublished)
            {
                if (MenuListener != null)
                {
                    OfficeApplication.MenuListener.DocumentPublished();
                }
            }
            else
            {
                if (MenuListener != null)
                {
                    OfficeApplication.MenuListener.NoDocumentPublished();
                }
            }
        }
Ejemplo n.º 10
0
        void Application_PresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
        {
            if (Pres.Name.ToLower().StartsWith("package"))
            {
                // parse packag id
                string number = Pres.Name.Substring(7, 5);
                int    packageID;
                if (Int32.TryParse(number, out packageID))
                {
                    if (Pres.Name.ToLower().Length < 13)
                    {
                        return;
                    }

                    string presName = Pres.Name.Substring(13);
                    if (presName.IndexOf("_") == -1)
                    {
                        return;
                    }
                    string userName = presName.Substring(0, presName.IndexOf("_"));

                    presName = presName.Substring(userName.Length);

                    if (!presName.EndsWith(".pptx") && presName.Length < 5)
                    {
                        return;
                    }
                    string passWord = presName.Substring(0, presName.Length - 5);
                    passWord = AuthenticateSAP.DecryptData(passWord.Substring(1));
                    if (AuthenticateSAP.ValidateUser(userName, passWord))
                    {
                        CreatePresentation pres = new CreatePresentation();
                        pres._fullName         = Path.GetFullPath(Pres.FullName);
                        pres._directoryPath    = Path.GetDirectoryName(Pres.FullName);
                        pres._xlsxLocationFile = pres._fullName.Replace(".pptx", ".xlsx");
                        pres.GeneratePresentation(packageID);
                    }
                }
            }
        }
Ejemplo n.º 11
0
 void Application_AfterPresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
 {
     AddCustomXmlPartToPresentation(Pres);
 }
 public void Start()
 {
     Sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
     Sr.RecognizeAsync(RecognizeMode.Multiple);
     pres = Globals.ThisAddIn.Application.Presentations.Open(location, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoTrue);
     pres = Globals.ThisAddIn.Application.ActivePresentation;
     pres.SlideShowSettings.Run();
 }
 void StartSlideShow()
 {
     pres = Globals.ThisAddIn.Application.Presentations.Open(location, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse, Office.MsoTriState.msoFalse);
     pres.SlideShowSettings.Run();
     pres.SlideShowWindow.Activate();
 }