forked from OfficeDev/open-xml-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
545b059
commit 4346e18
Showing
4 changed files
with
97 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 41 additions & 22 deletions
63
samples/presentation/retrieve_the_number_of_slides/vb/Program.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,54 @@ | ||
Imports DocumentFormat.OpenXml.Packaging | ||
Imports System | ||
Imports System.Linq | ||
|
||
Module Program | ||
Sub Main(args As String()) | ||
' <Snippet0> | ||
' <Snippet2> | ||
If args.Length = 2 Then | ||
RetrieveNumberOfSlides(args(0), args(1)) | ||
ElseIf args.Length = 1 Then | ||
RetrieveNumberOfSlides(args(0)) | ||
End If | ||
' </Snippet2> | ||
End Sub | ||
|
||
|
||
|
||
Public Function RetrieveNumberOfSlides(ByVal fileName As String, | ||
Optional ByVal includeHidden As Boolean = True) As Integer | ||
' <Snippet1> | ||
Function RetrieveNumberOfSlides(fileName As String, Optional includeHidden As String = "true") As Integer | ||
' </Snippet1> | ||
Dim slidesCount As Integer = 0 | ||
' <Snippet3> | ||
Using doc As PresentationDocument = PresentationDocument.Open(fileName, False) | ||
If doc.PresentationPart IsNot Nothing Then | ||
' Get the presentation part of the document. | ||
Dim presentationPart As PresentationPart = doc.PresentationPart | ||
' </Snippet3> | ||
|
||
If presentationPart IsNot Nothing Then | ||
' <Snippet4> | ||
If includeHidden.ToUpper() = "TRUE" Then | ||
slidesCount = presentationPart.SlideParts.Count() | ||
Else | ||
' </Snippet4> | ||
' <Snippet5> | ||
' Each slide can include a Show property, which if hidden | ||
' will contain the value "0". The Show property may not | ||
' exist, and most likely will not, for non-hidden slides. | ||
Dim slides = presentationPart.SlideParts.Where( | ||
Function(s) (s.Slide IsNot Nothing) AndAlso | ||
((s.Slide.Show Is Nothing) OrElse (s.Slide.Show.HasValue AndAlso s.Slide.Show.Value))) | ||
|
||
Using doc As PresentationDocument = | ||
PresentationDocument.Open(fileName, False) | ||
' Get the presentation part of the document. | ||
Dim presentationPart As PresentationPart = doc.PresentationPart | ||
If presentationPart IsNot Nothing Then | ||
If includeHidden Then | ||
slidesCount = presentationPart.SlideParts.Count() | ||
Else | ||
' Each slide can include a Show property, which if | ||
' hidden will contain the value "0". The Show property may | ||
' not exist, and most likely will not, for non-hidden slides. | ||
Dim slides = presentationPart.SlideParts. | ||
Where(Function(s) (s.Slide IsNot Nothing) AndAlso | ||
((s.Slide.Show Is Nothing) OrElse | ||
(s.Slide.Show.HasValue AndAlso | ||
s.Slide.Show.Value))) | ||
slidesCount = slides.Count() | ||
slidesCount = slides.Count() | ||
' </Snippet5> | ||
End If | ||
End If | ||
End If | ||
End Using | ||
|
||
Console.WriteLine($"Slide Count: {slidesCount}") | ||
|
||
Return slidesCount | ||
End Function | ||
End Module | ||
' </Snippet0> | ||
End Module |