Help for VBScript and retrieve number of page in PDF file

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Locked
Geo
Posts: 6
Joined: Tue Feb 28, 2006 4:10 pm
Location: Belgium, somewhere in Europe
Contact:

Help for VBScript and retrieve number of page in PDF file

Post by Geo »

Hello everyone,
I've never used the VBScript function NeoBook.
I try to use the following code, but does not.
By plainement against it functions in Excel.
The goal is to count the number of pages in PDF files in a folder.
Can you help me.
Thank you.

Code: Select all

'Function GetPageNum(PDF_File As String)
Dim PDF_File 'as string
Dim FileNum 'As Long
Dim strRetVal 'As String
Dim RegExp
Set RegExp = CreateObject("VBscript.RegExp")
RegExp.Global = True
RegExp.Pattern = "/Type\s*/Pages"
FileNum = FreeFile
Open PDF_File For Binary As #FileNum
strRetVal = Space(LOF(FileNum))
Get #FileNum, , strRetVal
Close #FileNum
GetPageNum = RegExp.Execute(strRetVal).Count
publication.nbSetVar "[PDFNombrePages]", GetPageNum
End Function
Sorry for my english very bad.
Bonjour à tous,
Je n'ai encore jamais utilisé la fonction VBScript de Neobook.
J'essaie d'utiliser le code suivant, mais ne fonctionne pas.
Par contre il fonctionne plainement dans Excel.
Le but est de compter le nombre de pages contenues dans les fichiers PDF d'un dossier.
Sauriez-vous m'aider.
Merci.
Geo
Posts: 6
Joined: Tue Feb 28, 2006 4:10 pm
Location: Belgium, somewhere in Europe
Contact:

Re: Help for VBScript and retrieve number of page in PDF fil

Post by Geo »

Hello forum

Hi Tony,
Lots of interesting things on your link.

I try to use the pdfinfo.exe utility.
On the command line, no problems

Code: Select all

pdfinfo.exe test1.pdf > txxt.txt
The txt file is created with the information.
In NeoBook, I use the command

Code: Select all

Run "[pubdir] pdfinfo.exe" "test1.pdf> txxt.txt" "RunOnce + Wait" "" ""
The TXT file not created (and I see briefly display the result in a command window)
An idea ?
Tanks
Tony Kroos
Posts: 419
Joined: Thu Oct 15, 2009 3:43 pm

Re: Help for VBScript and retrieve number of page in PDF fil

Post by Tony Kroos »

run it using console:
Run "cmd.exe /C [#34][pubdir]pdfinfo.exe[#34]" "test1.pdf> txxt.txt" "RunOnce + Wait" "" ""
dont forget to use quotes #34 if filepath has empty space(s)
maybe you should use "/C [#34][pubdir]pdfinfo.exe[#34] test1.pdf> txxt.txt" as run parameters (cant remember how run it properly, dont have nb installed to check it out)

you may run cmd.exe manually and test your run string until it works
Locked