3

I want to pass parameters to winword in order to read it in my vsto addin by using Environment.GetCommandLineArgs().

If a parameter-value contains a space I'm not able to escape the strings.

This is working:

winword.exe /myVar1:C:\folder\whatever1.doc /myVar2:C:\folder\somethingelese.txt C:\example.doc

This is not working:

winword.exe /myVar1:"C:\folder with space\whatever1.doc" /myVar2:"C:\folder with space 2\somethingelese.txt" C:\example.doc
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
wuhi
  • 174
  • 1
  • 8
  • If you haven't completely abandoned this, I noticed that the second example works for me when opening a Word 2007 template. Were you using a different version of Word? – Chris Nov 29 '12 at 19:03

1 Answers1

2

Try with the following command :

winword.exe "/myVar1:C:\folder with space\whatever1.doc" "/myVar2:C:\folder with space 2\somethingelese.txt" C:\example.doc

If it still doesn't work, send us the content of the array returned by GetCommandLineArgs.

Guillaume
  • 12,824
  • 3
  • 40
  • 48
  • What is the array returned by GetCommandLineArgs ? The bug may be in your code (maybe you are not reading the values properly). – Guillaume Sep 06 '11 at 15:02
  • here is the content - args {string[2]} string[] [0] "winword.exe" string [1] "/myVar1:C:\\folder with space\\whatever1.doc" string – wuhi Sep 06 '11 at 15:02
  • no. its a new instance. im sure its just a syntax problem ... without the quotes and spaces everything is ok :( – wuhi Sep 06 '11 at 15:10