Solved

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

Posted on 2013-05-29
5
752 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

762 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

20 Experts available now in Live!

Get 1:1 Help Now