Solved

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

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

772 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