Computer Hope
Microsoft => Microsoft Windows => Windows Vista and 7 => Topic started by: ritzg on December 13, 2011, 08:36:33 AM
-
Hi,
I have more than 100 rtf files in a folder on Windows 7. I'd like to print them out from the command line.
I have some code which will open a given rtf file in Word, print it and close it. Unfortunately, printing the the rtf files that I have must alter the files, since Word brings up the Save dialogue box when I try to close the file. So I have to manually close the file, obviously making it not as automatic as I'd like it.
Here's the command:
"C:\Program Files\Microsoft Office\Office12\winword.exe" test1.rtf /q /n /mFilePrintDefault /FileExit
This works fine, exempt for the prompt to save or not save the file. I'm looking for a command to discard all changes and close the file.
Any help would be appreciated.
-
Have you tried this method using Foxit which is a lightweight Free PDF app ? ?
-
No, I haven't tried Foxit.
Unfortunately, the place where I work locks down my computer, so I am not able to easily add new applications to it. I should have mentioned that in my original post.
-
Since Foxit Reader is a PDF reader and since you said nothing about PDF in your original post, I don't see that Foxit has any relevance here.
Regarding Word, if you were normally opening a Word file and made a change and then, when exiting, did not want to save the change, you could simply Click No when Word asks whether you want to save the changes. Can you do that via your command line?
-
Hi,
I am definitely looking to print rtf files, not pdf files, at this time.
If I understand your reply, you are suggesting that I "click no" from the command prompt. Unfortunately, I don't know how to issue a "Click No" command from a command prompt. Is this possible?
-
I don't know how to issue a "Click No" command from a command prompt. Is this possible?
I don't know. Hopefully, someone else will have an answer.
-
I just did this with a file called document.rtf and Word opened the file, printed it, and quit without asking me if I wanted to save it.
"C:\Program Files (x86)\Microsoft Office\OFFICE11\WINWORD.EXE" Document.rtf /q /n /mFilePrintDefault /mFileExit
Obviously I had to adapt the path to WINWORD.EXE for my system, so the question arises why does Word bring up (I presume) the Save As dialog?. This can happen from the Word Print button if the printer is not configured correctly, so I would check that out.
-
Did you try with the /x switch?
-
I just did this with a file called document.rtf and Word opened the file, printed it, and quit without asking me if I wanted to save it.
"C:\Program Files (x86)\Microsoft Office\OFFICE11\WINWORD.EXE" Document.rtf /q /n /mFilePrintDefault /mFileExit
Obviously I had to adapt the path to WINWORD.EXE for my system, so the question arises why does Word bring up (I presume) the Save As dialog?. This can happen from the Word Print button if the printer is not configured correctly, so I would check that out.
That Worked for me as well.
-
Hoping the above works, but if not, an AutoIt script would do the trick (it could click on any buttons as needed). http://www.autoitscript.com/site/autoit/
-
Well color me embarrassed...i read rtf to be PDF...
Sorry///my bad.
-
You must be poonished.
-
;D
:o
-
Hi,
Thanks for all of the tips.
I tried the /x switch. It seemed to work the same way as before. It brings up the same "Saves changes" dialogue box, just like before.
I think my rtf file might have something different in it that is causing Word to modify it when I print it. Checking out the print settings seems like a good idea. Unfortunately, I'm such a newbie for things like this that I don't know what I'm looking for.
I'll check out AutoIT.
Glenn
-
What version of Word are you using? There could be some unseen nuances between different Word versions that could be causing this issue.
-
What version of Word are you using? There could be some unseen nuances between different Word versions that could be causing this issue.
C:\Program Files\Microsoft Office\Office12\winword.exe
Word 2007
-
You could try using wordpad instead of word, like this:
write /p test1.rft
-
Word 2007
It also works as is (with a short file name, of course) with Word 6.
-
You could try using wordpad instead of word, like this:
write /p test1.rft
Wow. That is pure logic. Not sure why we all were fixated on doing it with word.