Computer Hope

Microsoft => Microsoft Windows => Windows Vista and 7 => Topic started by: ritzg on December 13, 2011, 08:36:33 AM

Title: Batch Print *.rtf files with Word
Post 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.
Title: Re: Batch Print *.rtf files with Word
Post by: patio on December 13, 2011, 08:44:35 AM
Have you tried this method using Foxit which is a lightweight Free PDF app ? ?
Title: Re: Batch Print *.rtf files with Word
Post by: ritzg on December 13, 2011, 09:37:41 AM
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.
Title: Re: Batch Print *.rtf files with Word
Post by: soybean on December 13, 2011, 09:45:29 AM
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? 
Title: Re: Batch Print *.rtf files with Word
Post by: ritzg on December 13, 2011, 10:22:14 AM
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?

Title: Re: Batch Print *.rtf files with Word
Post by: soybean on December 13, 2011, 11:06:48 AM
Quote
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. 
Title: Re: Batch Print *.rtf files with Word
Post by: Salmon Trout on December 13, 2011, 11:51:25 AM
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.

Code: [Select]
"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.

Title: Re: Batch Print *.rtf files with Word
Post by: Squashman on December 13, 2011, 12:04:46 PM
Did you try with the /x switch?
Title: Re: Batch Print *.rtf files with Word
Post by: Squashman on December 13, 2011, 12:10:36 PM
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.

Code: [Select]
"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. 
Title: Re: Batch Print *.rtf files with Word
Post by: Rob Pomeroy on December 13, 2011, 12:58:02 PM
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/
Title: Re: Batch Print *.rtf files with Word
Post by: patio on December 13, 2011, 01:20:44 PM
Well color me embarrassed...i read rtf to be PDF...

Sorry///my bad.
Title: Re: Batch Print *.rtf files with Word
Post by: Rob Pomeroy on December 14, 2011, 06:52:20 AM
You must be poonished.
Title: Re: Batch Print *.rtf files with Word
Post by: patio on December 14, 2011, 07:16:24 AM
 ;D

                      :o
Title: Re: Batch Print *.rtf files with Word
Post by: ritzg on December 15, 2011, 07:53:11 AM
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

Title: Re: Batch Print *.rtf files with Word
Post by: Raven19528 on December 15, 2011, 04:45:37 PM
What version of Word are you using? There could be some unseen nuances between different Word versions that could be causing this issue.
Title: Re: Batch Print *.rtf files with Word
Post by: Salmon Trout on December 15, 2011, 11:53:10 PM
What version of Word are you using? There could be some unseen nuances between different Word versions that could be causing this issue.

Quote from: The OP
C:\Program Files\Microsoft Office\Office12\winword.exe

Word 2007


Title: Re: Batch Print *.rtf files with Word
Post by: oldun on December 16, 2011, 02:04:14 AM
You could try using wordpad instead of word, like this:

Code: [Select]
write /p test1.rft
Title: Re: Batch Print *.rtf files with Word
Post by: BC_Programmer on December 16, 2011, 03:21:58 AM
Word 2007

It also works as is (with a short file name, of course) with Word 6.
Title: Re: Batch Print *.rtf files with Word
Post by: Squashman on December 16, 2011, 05:19:49 AM
You could try using wordpad instead of word, like this:

Code: [Select]
write /p test1.rft
Wow.  That is pure logic. Not sure why we all were fixated on doing it with word.