void _PowerPointApplication_ColorSchemeChanged(Microsoft.Office.Interop.PowerPoint.SlideRange SldRange) { DisplayInWatchWindow(ColorSchemeChanged++, System.Reflection.MethodInfo.GetCurrentMethod().Name); }
private void button3_Click(object sender, EventArgs e) { if (this.textBox1.Text == "") { MessageBox.Show("内容がないため、録音作業を中止しました。"); return; } bool isSucess = true; string nowtimestr = DateTime.Now.ToFileTime().ToString(); string fileName = nowtimestr; string appPath = Directory.GetCurrentDirectory(); string strtemp = Globals.ThisAddIn.Application.ActivePresentation.Name.Replace(".pptx", ""); appPath = appPath + @"\" + strtemp + @"\Recode\"; if (Directory.Exists(appPath) == false)//フォルダがなければ、フォルダを新規する { Directory.CreateDirectory(appPath); } if (null != this.spVoiceTts) { this.spVoiceTts.Pause(); } SpVoice saveVoiceTts = new SpVoice(); // 音声合成のオブジェクト saveVoiceTts.Voice = saveVoiceTts.GetVoices("", "").Item(this.listBox2Language.SelectedIndex); saveVoiceTts.Volume = (int)numericUpDown1Vol.Value; saveVoiceTts.Rate = (int)numericUpDown2Speed.Value; string strFullFileName = appPath + @"\" + fileName + @".wav"; SpFileStream fs = null; try { fs = new SpFileStream(); fs.Open(strFullFileName, SpeechStreamFileMode.SSFMCreateForWrite, false); saveVoiceTts.AudioOutputStream = fs; saveVoiceTts.Speak(this.textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault); } catch (Exception ex) { isSucess = false; System.Windows.Forms.MessageBox.Show(ex.ToString()); } finally { if (fs != null) { fs.Close(); } } if (isSucess == false) { MessageBox.Show("作成失敗しました。音声設定の設定を見直してから、もう一回試して見てください。"); return; } //Powerpoint File Object Microsoft.Office.Interop.PowerPoint.Application pptApplication = Globals.ThisAddIn.Application; //現在のスライド番号 int slideNumber = pptApplication.ActiveWindow.Selection.SlideRange.SlideNumber; Microsoft.Office.Interop.PowerPoint.SlideRange slideNow = pptApplication.ActivePresentation.Slides.Range(slideNumber); string strTemp = "\n"; //音声ファイルを追加 slideNow.Shapes.AddMediaObject2(strFullFileName, Microsoft.Office.Core.MsoTriState.msoCTrue, Microsoft.Office.Core.MsoTriState.msoCTrue, -10, -10, 50, 50); //セリフ文字をノート欄に追加 slideNow.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text += strTemp + "\n" + "※" + this.textBox1.Text + strTemp; MessageBox.Show("音声ファイルを追加しました!\n" + strFullFileName); //成功した場合、フォルダを開ける //System.Diagnostics.Process.Start(appPath); }