Solved

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

Posted on 2013-05-29
5
776 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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 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.

733 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