Skip to content

Commit

Permalink
Macros
Browse files Browse the repository at this point in the history
  • Loading branch information
KonduruKeerthi committed Aug 30, 2024
1 parent 6d50c7a commit 0331f07
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.pptm">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Empty file.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Syncfusion.Presentation;

//Load or open an PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"../../../Data/Template.pptm"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptm"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint presentation.
using IPresentation pptxDoc = Presentation.Open(inputStream);
//Add a blank slide to the presentation.
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank);
//Add a text box to the slide.
IParagraph paragraph = slide.Shapes.AddTextBox(100, 100, 300, 80).TextBody.AddParagraph("Preserve Macros");
//Save the PowerPoint Presentation as stream.
using FileStream outputStream = new(Path.GetFullPath(@"../../../Result.pptm"), FileMode.Create, FileAccess.ReadWrite);
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptm"), FileMode.Create, FileAccess.ReadWrite);
pptxDoc.Save(outputStream);
Empty file.
4 changes: 2 additions & 2 deletions Macros/Remove-macros/.NET/Remove-macros/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Syncfusion.Presentation;

//Load or open an PowerPoint Presentation.
using FileStream inputStream = new(Path.GetFullPath(@"../../../Data/Template.pptm"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
using FileStream inputStream = new(Path.GetFullPath(@"Data/Template.pptm"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint presentation.
using IPresentation pptxDoc = Presentation.Open(inputStream);
//Check whether the presentation has macros and then removes them.
if (pptxDoc.HasMacros)
pptxDoc.RemoveMacros();
//Save the PowerPoint Presentation as stream.
using FileStream outputStream = new(Path.GetFullPath(@"../../../Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
using FileStream outputStream = new(Path.GetFullPath(@"Output/Result.pptx"), FileMode.Create, FileAccess.ReadWrite);
pptxDoc.Save(outputStream);
9 changes: 9 additions & 0 deletions Macros/Remove-macros/.NET/Remove-macros/Remove-macros.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@
<PackageReference Include="Syncfusion.Presentation.NET" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Template.pptm">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Output\.gitkeep">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>

0 comments on commit 0331f07

Please sign in to comment.