public void RunExample() { // start powerpoint PowerPoint.Application powerApplication = new PowerPoint.Application(); // create a utils instance, not need for but helpful to keep the lines of code low CommonUtils utils = new CommonUtils(powerApplication); // add a new presentation with two new slides PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide1 = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); PowerPoint.Slide slide2 = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // add shapes slide1.Shapes.AddShape(MsoAutoShapeType.msoShape4pointStar, 100, 100, 200, 200); slide2.Shapes.AddShape(MsoAutoShapeType.msoShapeDoubleWave, 200, 200, 200, 200); // change blend animation slide1.SlideShowTransition.EntryEffect = PpEntryEffect.ppEffectCoverDown; slide1.SlideShowTransition.Speed = PpTransitionSpeed.ppTransitionSpeedFast; slide2.SlideShowTransition.EntryEffect = PpEntryEffect.ppEffectCoverLeftDown; slide2.SlideShowTransition.Speed = PpTransitionSpeed.ppTransitionSpeedFast; // save the document string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example04", PowerPoint.Tools.DocumentFormat.Normal); presentation.SaveAs(documentFile); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); // show dialog for the user(you!) HostApplication.ShowFinishDialog(null, documentFile); }
public void RunExample() { // start powerpoint PowerPoint.Application powerApplication = new PowerPoint.Application(); // create a utils instance, not need for but helpful to keep the lines of code low CommonUtils utils = new CommonUtils(powerApplication); // add a new presentation with one new slide PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // add a chart slide.Shapes.AddOLEObject(120, 111, 480, 320, "MSGraph.Chart", "", MsoTriState.msoFalse, "", 0, "", MsoTriState.msoFalse); // save the document string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example05", PowerPoint.Tools.DocumentFormat.Normal); presentation.SaveAs(documentFile); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); // show dialog for the user(you!) HostApplication.ShowFinishDialog(null, documentFile); }
public void RunExample() { bool isFailed = false; string documentFile = null; PowerPoint.Application powerApplication = null; try { // start powerpoint powerApplication = new PowerPoint.Application(); // create a utils instance, not need for but helpful to keep the lines of code low CommonUtils utils = new CommonUtils(powerApplication); // add a new presentation with one new slide PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // add new module and insert macro. the option "Trust access to Visual Basic Project" must be set VB.CodeModule module = presentation.VBProject.VBComponents.Add(vbext_ComponentType.vbext_ct_StdModule).CodeModule; string macro = string.Format("Sub NetOfficeTestMacro()\r\n {0}\r\nEnd Sub", "MsgBox \"Thanks for click!\""); module.InsertLines(1, macro); // add button and connect with macro PowerPoint.Shape button = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeActionButtonForwardorNext, 100, 100, 200, 200); button.ActionSettings[PpMouseActivation.ppMouseClick].AnimateAction = MsoTriState.msoTrue; button.ActionSettings[PpMouseActivation.ppMouseClick].Action = PpActionType.ppActionRunMacro; button.ActionSettings[PpMouseActivation.ppMouseClick].Run = "NetOfficeTestMacro"; // save the document documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example03", PowerPoint.Tools.DocumentFormat.Macros); presentation.SaveAs(documentFile); } catch (System.Runtime.InteropServices.COMException throwedException) { isFailed = true; HostApplication.ShowErrorDialog("VBA Error", throwedException); } finally { // close power point and dispose reference if (powerApplication != null) { powerApplication.Quit(); powerApplication.Dispose(); } if ((null != documentFile) && (!isFailed)) HostApplication.ShowFinishDialog(null, documentFile); } }
public void RunExample() { // start powerpoint PowerPoint.Application powerApplication = new PowerPoint.Application(); // create a utils instance, not need for but helpful to keep the lines of code low CommonUtils utils = new CommonUtils(powerApplication); // add a new presentation with one new slide PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); presentation.Slides.Add(1, PpSlideLayout.ppLayoutClipArtAndVerticalText); // save the document string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example01", PowerPoint.Tools.DocumentFormat.Normal); presentation.SaveAs(documentFile); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); // show dialog for the user(you!) HostApplication.ShowFinishDialog(null, documentFile); }
public void RunExample() { // start powerpoint PowerPoint.Application powerApplication = new PowerPoint.Application(); // create a utils instance, not need for but helpful to keep the lines of code low CommonUtils utils = new CommonUtils(powerApplication); // add a new presentation with one new slide PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // add a label PowerPoint.Shape label = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 600, 20); label.TextFrame.TextRange.Text = "This slide and created Shapes are created by NetOffice example."; // add a line slide.Shapes.AddLine(10, 80, 700, 80); // add a wordart slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, "This a WordArt", "Arial", 20, MsoTriState.msoTrue, MsoTriState.msoFalse, 10, 150); // add a star slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250); // save the document string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example02", PowerPoint.Tools.DocumentFormat.Normal); presentation.SaveAs(documentFile); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); // show dialog for the user(you!) HostApplication.ShowFinishDialog(null, documentFile); }
/// <summary> /// Creates an instance of the class /// </summary> /// <param name="owner">owner instance</param> protected internal ApplicationUtils(CommonUtils owner) { if (null == owner) throw new ArgumentNullException("owner"); _owner = owner; }