Solved

Trying to capture GhostScript error using command line exe using VBA shell..

Posted on 2013-05-29
5
760 Views
Last Modified: 2013-06-09
I an trying to capture the return error code from running GostScript at the command line, running it using Shell in VBA. The aim is to use it to check that a pdf file is not corrupted and will actually open.

I have around 2,000 pdf files some very old of Genealogical data. If a pdf is corrupted, when trying to open with Adobe Reader it freezes and locks everything up with no way out (except by Ctrl+Alt+Del and stopping the Adobe Reader.

The code I am using is:
pdfShell.Run """C:\Program Files\gs\gs9.07\bin\gswin32c.exe"" -o nul -sDEVICE=nullpage """ & gsPDF & """", 0, True
pdfShell.PopUp Err.Number, 5, "Problem", vbCritical + vbSystemModal


At this point the only error number I get back is 0 (indicating that GhostScript ran successfully) but not any error it generated. When I run in a DOS window I do see the error displayed by GhostScript (doesn't help).

Any assistance or other way of doing it would be appreciated.
Gary
0
Comment
Question by:AIGS
  • 2
5 Comments
 
LVL 84
ID: 39204106
What is "pdfShell", and how was it created?
0
 

Author Comment

by:AIGS
ID: 39204127
Set pdfShell = CreateObject("WScript.Shell")

Create shell object.
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 39233100
I think you need to direct one of the output streams to a file and inspect the file.  I think the number two stream is usually the error stream, but that might only apply for OS commands.
Look at Rob's documentation and play with your batch file.
http://www.robvanderwoude.com/redirection.php
0
 

Author Closing Comment

by:AIGS
ID: 39233539
Thanks for the advice. It has proven to be worthwhile and with a little tweaking I believe I will be able to get the result I am after.

Gary
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now