• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Running powershell commansd from VBA

JonWayn70

New Member
I am trying to use powershell to extract pages from pdf files. This functionality comes from PDFtk. The pdftk executable resides under program files (x86)\subfolders, which is one of the problems, even though I quote the path.

One example of the failed command is:

Cmd = "powershell -noexit ""C:\Program Files (x86)\PDFtk\bin\pdftk"" """ & FilePth & """ cat " & Rng & " output """ & Pth & OutFile & """"

The console returns error: x86 : The term 'x86' is not recognized as the name of a cmdlet

I have also tried passing in a script block, to change the current directory to the pdfpk location, and it still doesnt work.

So, I wonder what it is that I am doing wrong, or should be doing.

Any help will be appreciated
 
What is the correct string under DOS command ?​
Once it works manually then just compare the string with the one you generate under VBA …​
 
As it's not always the same than under DOS command in order to launch under VBA​
- can be done without PowerShell obviously like you can find on web for PDFtk -​
so the good start from is not the console, as guessing can't be coding …​
 
Ok, I got it to work simply by getting rid of powershell and calling the exe of PDFtk directly . Thank you for the insight
 
Last edited by a moderator:
Back
Top