stenci
stenci

Reputation: 8481

Executing Ghostscript on a 64 bit command shell from Excel VBA

My Excel VBA macro creates a the gs.cmd file containing the following lines:

"C:\Program Files\gs\gs9.10\bin\gswin64c.exe" @gsparams
echo %ProgramFiles%
pause

Then executes Shell "gs.cmd".

The resulting PDF file generated by Ghostscript misses a few links and the console shows C:\Program Files (x86).

If I start a cmd.exe from the Start menu and execute the same gs.cmd script, the resulting PDF file is correct and the console shows C:\Program Files.

The PDF file it contains many 36"x24" CAD drawings, with mostly vector content and a few large bitmaps, with hundreds of bookmarks and thousands of links defined in the pdfmarks file.

The only difference I see between the executions is that one seems to be 32 bit and the other 64 bit.

I don't understand why Ghostscript makes a perfect job in the 64 bit instance, but in the 32 bit instance does most of the job correctly and it just misses the creation of about 5% of the links. I would expect for it to either fail or work.

I googled around to see if I could get the Shell to run in a 64 bit environment, but I didn't find a solution.

How can I do to fix the problem?

Upvotes: 1

Views: 2074

Answers (1)

yms
yms

Reputation: 10418

What about creating a second .cmd file that launches the cmd version that you want?

It may look like this:

launcher.cmd :

%SYSTEMROOT%\System32\cmd.exe /c c:\temp\gs.cmd

The 32 bit version of cmd.exe will be inside %SYSTEMROOT%\Syswow64\ on 64 bit systems. On a 32 bit system I guess the script will use the only cmd.exe available (%SYSTEMROOT%\System32\cmd.exe) so no problem there.

Upvotes: 1

Related Questions