Hi Wouter,
I believe this should solve you "print print print" problem. It can easily be
modified to open a number of files located in a particular folder or use
wildcards, etc, instead of just one.
Copy this into notepad and save it with a .VBS extension somewhere and then
execute it to your heart's content.
'
option explicit
dim oWordApp, oWordDoc, strWordDoc, nNumCopies
strWordDoc = "c:\temp\someword.doc"
nNumCopies = 3
set oWordApp = CreateObject("Word.Application")
oWordApp.Visible = true
set oWordDoc = oWordApp.Documents.Open(strWordDoc)
while nNumCopies <> 0
oWordDoc.PrintOut
nNumCopies = nNumCopies - 1
wend
oWordDoc.Close
set oWordDoc = nothing
oWordApp.Quit
set oWordApp = nothing
'
-Mario
Quoting Wouter van Ooijen :
>> But I have done a quite a bit of scripting in MS Windows
>> using vbscript,
>> sendkeys, sidekick, etc... With various degrees of success.
>
> But vbscript is not 'the' scripting language of windows applications, it
> just happens to be the inside engine of most Microsoft apps. It won't do
> you much good to automate a task using let's say Firefox.
>
> One problem I had is that I create invoices from an administration
> program (I wrote that myself, in Python), and I want to print them in a
> nice format. I used to have a letterhead in Word, print that on a stack
> of paper, the invoice itself was in html, and I used IE to print that (I
> could not get Firefox to print by default without any headers or
> footers). I had to do that by hand: open the file, print print print (I
> need 3 copies), open next file, etc. I switched to generating rtf, so I
> can have the letterhead and invoice proper in one file, but I would
> still have to open Word, print print print, open next file etc. I could
> not find a Word command line option to cause it to open the file, print
> it, and quit. I recently learned that this can easily be done by
> specifying a macro to run. That macro still can't print 3 times (I dunno
> why, it simply does not work), but I can start Word with the macro 3
> times, no problem.
>
> The point of this is that Word is a typical GUI program, and with its
> macro/scription facility it is not too closed. But to do something basic
> (print a file) in an automated way (what else are computers for!) I must
> first get the idea that this can (only) be done by a startup macro, and
> I have to learn the language for that macro. (OK, google helps a lot for
> both) A decent CLI application would provide a documented way to do this
> from the command line...
>
> Note that this is a GUI issue, not a Microsoft issue. Firefox is even
> worse that IE in this tiny aspect.
>
>> And CLI scripting in Windows systems is very much alive and well, so
>> wouldn't it be nice to have a GUI of the command line
>> utilities? E.g. the
>> standard Win32 command line stuff like SORT, DIR, etc...
>> Should have GUI
>> interfaces accessible from the command line as menu pull
>> downs or popups.
>
> I realy don't see any use for that
>
>> I've always loved that quote about Unix being very friendly, but very
>> selective about it's friends. Perl seems that way to me as well.
>
> not a friend of mine. Python has eaten it alive.
>
> Wouter van Ooijen
>
> -- -------------------------------------------
> Van Ooijen Technische Informatica: www.voti.nl
> consultancy, development, PICmicro products
> docent Hogeschool van Utrecht: www.voti.nl/hvu
>
>
> --
> http://www.piclist.com PIC/SX FAQ & list archive
> View/change your membership options at
> http://mailman.mit.edu/mailman/listinfo/piclist
>
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist