?
Solved

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

Posted on 2013-05-29
5
Medium Priority
?
796 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 85
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 46

Accepted Solution

by:
aikimark earned 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Six Sigma Control Plans
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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