Share via

special characters in word macro shell command

Anonymous
2013-05-29T18:34:07+00:00

I am running an outside exec through the word macro using Shell command but the argument of the executable requires two % signs (%%) which seems to cause a problem with the Shell command. When I execute the following from command line directly it works:

gswin64c.exe -o output%%02.png input.pdf

and it produces the correct output of png files (output01.png, output02.png, output03.png etc)...

but when I do this

Shell("gswin64c.exe -o output%%02.png input.pdf")

this produces a single file named output%02.png -- not the expected behaviour like above... I am assuming it's the %% sign that's causing the problem.

How should I correctly pass the %% sign in the Shell command?

Many thanks, in advance!

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2013-05-29T20:00:19+00:00

    Hi Jeeped, thanks for your reply -- 4% signs didn't work but 3 worked somehow... The output filename has a % sign now (output%01.png, output%02.png etc.) but at least I get the several output files I needed. Thanks for your answer!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-05-29T19:03:17+00:00

    I have no way to test this at the moment but it would appear that the first % is being interpreted as an escape character. if this is true, you will have to double up the % signs much as you would to put a quote within a quoted string.

    Shell("gswin64c.exe -o output%%%%02.png input.pdf")

    Was this answer helpful?

    0 comments No comments