Export Graphics
After running workflow.R, a PowerPoint slide deck should have been created that contains one slide for each subwatershed graphic. Follow the below steps to export the graphics to image files:
Open SCI_graphics.pptx
Save slide deck as a .pptm so that it can handle macros
In the View tab, click Macros
Type in a new Macro Name, such as “exportSlides”. Click Create
-
Copy in the Excel VBA code
Sub exportSlides() On Error Resume Next MkDir "C:\Users\example_user\Git\SCI\output\graphics\" Dim osld As Slide For Each osld In ActivePresentation.Slides osld.Export "C:\Users\example_user\Git\SCI\output\graphics\" & Getname(osld), "PNG" Next osld End Sub Function Getname(osld As Slide) As String Dim strTitle As String Dim nonValid() As String Dim i As Integer If osld.Shapes.HasTitle Then If osld.Shapes.Title.TextFrame.HasText Then strTitle = osld.Shapes.Title.TextFrame.TextRange End If End If If Len(strTitle) < 1 Then strTitle = "Slide" & CStr(osld.SlideIndex) 'strips SOME non valid characters 'make sure titles do not contain any others nonValid = Split("\$/$:$.$,$?$*$<$>$", "$") For i = 1 To UBound(nonValid) strTitle = Replace(strTitle, nonValid(i), "") Next i 'Replace spaces with underscores strTitle = Replace(strTitle, " ", "_") Getname = CStr(osld.SlideIndex) & "_" & strTitle & ".png" End Function
In the macro sub, update the two file paths with the location where you want the graphics to be saved
Click the Run button (or hit F5)
Note: A transparent background is not possible with this macro. If a transparent image background is required, complete the following steps for each individual PowerPoint slide:
Select all five individual images (drag mouse over entire slide to select)
Right click, Group all five images (if the Group button is disabled, may need to cut and re-paste images and try grouping again)
Right click grouped image, Save as Picture
Choose file destination. Save as .png file type