pdfinfo to get Page Count

    Function GetPageCount(sFile As String) As Integer

        Dim myprocess As New Process

        Debug.Print(sFile)

        '"\\cswis001\il\MEDENTChadCantDoItHa\pdfinfo.exe"

        'Program you want to launch execute etc.

        'myprocess.StartInfo.FileName = "c:\windows\system32\openfiles.exe"

        myprocess.StartInfo.FileName = "pdfinfo.exe"

        myprocess.StartInfo.Arguments = Chr(34) & sFile & Chr(34) '& " " & "|C:\Windows\System32\grep.exe -i " & Chr(34) & "Pages: " & Chr(34)

        'myprocess.StartInfo.WorkingDirectory = sTEMPpath

        'myprocess.StartInfo.UserName = "xsvcacct"

        'myprocess.StartInfo.Password = LoadSecureString("RunM3n0w")

        'myprocess.StartInfo.Domain = "CHNET"

        'This is important.  Since this is a windows service it will run

        'even though no one is logged in.

        'Therefore there is not desktop available so you better

        'not show any windows dialogs

        myprocess.StartInfo.UseShellExecute = False

        myprocess.StartInfo.CreateNoWindow = True

        ''We want to redirect the output from the openfiles call to the program

        ''Since there won't be any window to display it in

        myprocess.StartInfo.RedirectStandardOutput = True

        'myprocess.StartInfo.RedirectStandardInput = True

        myprocess.StartInfo.RedirectStandardError = True

        myprocess.StartInfo.StandardOutputEncoding = Text.Encoding.ASCII

        'myprocess.StartInfo.RedirectStandardOutput = False

        Debug.Print(myprocess.StartInfo.FileName & " " & myprocess.StartInfo.Arguments)

        myprocess.Start()

        Dim sErrText As String = myprocess.StandardError.ReadToEnd()

        Debug.Print(sErrText)

        If Len(sErrText) > 0 Then

            Return -1

        Else

            Dim sPages As String = myprocess.StandardOutput.ReadToEnd()

            Debug.Print("grab : " & funGrabBetween(sPages, "Pages:", vbCrLf))

            Return Val(funGrabBetween(sPages, "Pages:", vbCrLf))

        End If

        'Dim sOutput As String

        'Using oStreamReader As System.IO.StreamReader = myprocess.StandardOutput

        '    sOutput = oStreamReader.ReadToEnd()

        'End Using

    End Function

 http://www.xpdfreader.com/download.html

Count Characters Function

    Public Function CountCharacter(ByVal value As String, ByVal ch As Char) As Integer

        Return value.Count(Function(c As Char) c = ch)

    End Function