Searching \ for '[EE] Open word doc and print 3 times script,was: T' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/timers.htm?key=time
Search entire site for: 'Open word doc and print 3 times script,was: T'.

Exact match. Not showing close matches.
PICList Thread
'[EE] Open word doc and print 3 times script,was: T'
2007\01\25@233847 by Tony Smith

picon face
{Quote hidden}

Having oWordDoc.Printout Copies:=3 will save a little bit of typing.

The next step is to integrate the script into the shell, so when you
right-click a Word doc, you get an extra option, like "Print triplicate".
The filename gets passed to the .vbs script.

To print multiple files, you select (highlight) them all, right-click,
"Print triplicate".  The script will then run once for each file.

In theory FireFox should be scriptable the same way Word is above.

Tony

2007\01\26@021003 by Wouter van Ooijen

face picon face
> The next step is to integrate the script into the shell, so when you
> right-click a Word doc, you get an extra option, like "Print
> triplicate". The filename gets passed to the .vbs script.
>
> To print multiple files, you select (highlight) them all, right-click,
> "Print triplicate".  The script will then run once for each file.

That is eaxctly the direction I don't want/need: I want to print the
files without intervention. I don't even want to select the files to
print: my Python script does that for me. And after the printing, it
moves the files to a 'done' directory. And just for completeness: it
does not print 3 copies of each file, it prints 2 copies of each file,
and then prints 1 copy of each file. I copy is for my archive, so now I
don't have to gather those single copies from the pile.

Someone else mentioned a Python interface to OpenOffice: I will
certainly look into that!

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu


2007\01\26@041402 by Tony Smith

picon face
{Quote hidden}

Oh, I see, you mixed up VBScript & VBA in your earlier message.  VBA is the
macro language used by Word, XL etc, and VBScript is a stripped down version
usd by Windows.

VBScript doesn't really do all that much, it just manipulates other stuff.
(Frankly, VBS is pretty braindead, but it's supposed to be).

Your Python script should be more-or-less doing what Mario posted.  You
treat Word as a component, that's the point of COM.  Relying on a macro
within the Word doc itself (or as an add-in) is usually a bad way to do it.

You can call a VBScript from the commandline or wherever too, so you could
have "PrintAndMove.vbs c:\current\file.doc c:\archive\"; the .vbs picks up
the file to be printed, and the dir to move it to afterwards.

There is a .Run() method to trigger macros within Word when being opened by
a scripting lanugage.

Tony

2007\01\26@060222 by Wouter van Ooijen

face picon face
> Your Python script should be more-or-less doing what Mario
> posted.  You
> treat Word as a component, that's the point of COM.

Probably, but I never mastered (or even looked into) COM. I just start
(from Python) a 'dos' command start starts word with the file and a
macro that prints the current document and exits. Probably dirty, but
simple for me and it does the job. The opening and closing of word
windows is a minor nuisance, but not a real problem.

> Relying on a macro
> within the Word doc itself (or as an add-in) is usually a bad
> way to do it.

I agree about an internal macro (if it autostarts you would not be able
to view/edit the document any more!) but I don't see why an external
macro would be a bad way to do it?

> have "PrintAndMove.vbs c:\current\file.doc c:\archive\"; the
> .vbs picks up
> the file to be printed, and the dir to move it to afterwards.

Possible, but I do everything in Python unless there are pressing
reasons to do otherwise. So the moving is done in Python, no problem
with that.

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu


2007\01\26@072717 by John La Rooy

flavicon
face
On 1/26/07, Tony Smith <spam_OUTajsmithTakeThisOuTspamrivernet.com.au> wrote:

{Quote hidden}

I'm not a heavy windows user, but I had the impression that automating
stuff
like this in windows takes over the desktop/focus and makes the computer
unusable for anything else while it's running. I'd definitely find it more
interesting
if that stuff can run in the background.

2007\01\26@082712 by Alan B. Pearce

face picon face
> I'm not a heavy windows user, but I had the impression that automating
>stuff
>like this in windows takes over the desktop/focus and makes the computer
>unusable for anything else while it's running. I'd definitely find it more
>interesting
>if that stuff can run in the background.

I have done it to make an automated test system using VB3 and WORD running
on Win3.1. The trick to it is finding the names for the hooks that MS has
put into the Office tools. I believe this is where .NET is supposed to be a
lot better than all their previous methods.

2007\01\26@090928 by Tony Smith

picon face


{Quote hidden}

Extenal macros are fine, that the point of COM, to enable applications to be
controlled by something else.  I do a lot of work where something like an
Access database generates a Word document.

I'm not familiar with Python, but I'd assume a fairly new language would
handle COM.  A quick rummage turned up this:
www.darkcoding.net/software/printing-word-and-pdf-files-from-python/,
which looks remarkably like the VBS version, apart from the French.  :)

He mentions that you may get warning messages, but there's a property to
disable those, something like Word.ShowWarnings = False.

By adding Word.Visible = False, the user (ie you) won't see the doc open &
close.

In the .Open(), I'd include AddToRecentFiles := False, and ReadOnly := True.
These flags means it doesn't get added to the recent files (MRU) list, and
won't hassle you to save it if you have auto fields that update.

Tony

2007\01\26@092143 by Tony Smith

picon face
{Quote hidden}

As usual, it depends on what you're automating an how you do it.  When you
open Word from a script, you usually create a whole new copy (instance) so
you don't interfere with what's already running.  Focus doesn't switch, it
remains with whatever you were running.

You can choose whether the user can see the application as well.  Of course,
they're going to notice the performance hit when you open Excel and start
processing a 250Mb in the background.  Putting Word.Activate into the script
will make it take focus.

Something like Outlook only allows one copy at a time to run, so automating
that can be a problem.

Yesterday I spent some time adding 'Send to XL' buttons to some Access
forms.  Yeah, Access already has this (or you can cut/paste) but what this
does was open XL, copy the data over, fix up the headings, apply formatting,
rename the sheet, set the file name, and then makes XL visible.  If an XL
file of the same name was already opened, then it added the data as a new
sheet.

The way Wouter is doing it (shelling out) will cause Word to be visible, and
take the focus.  His document has a macro in it the trigger printing and
closing, but the user still can cause problems (& vice versa).

Tony

2007\01\26@092958 by Alan B. Pearce

face picon face
>By adding Word.Visible = False, the user (ie you)
>won't see the doc open & close.

Can also produce interesting message boxes when you close Windows, if word
hasn't shut each instance down correctly.

Having seen umpteen "do you want to save document" messages on attempting to
shut down, I tend to allow it to show the document.

2007\01\26@100844 by Tony Smith

picon face
> >By adding Word.Visible = False, the user (ie you) won't see the doc
> >open & close.
>
> Can also produce interesting message boxes when you close
> Windows, if word hasn't shut each instance down correctly.
>
> Having seen umpteen "do you want to save document" messages
> on attempting to shut down, I tend to allow it to show the document.


Opening the docs as read-only solves that (I think!).

There's also the .Saved flag, setting that to True allows a clean shutdown
even if the contents have been altered, or when you .Close a doc, there's a
SaveChanges option (true/false) there as well.

Tony

2007\01\26@102108 by Wouter van Ooijen

face picon face
> I'm not familiar with Python, but I'd assume a fairly new
> language would handle COM.

Pyhthon can handle COM, but I can't (that is: I'd rather spend that time
on other things). I prefer what I know (and what will work on other
OS'es): a command line!

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu


2007\01\26@102108 by Wouter van Ooijen

face picon face
> His document has a macro in it the trigger
> printing and closing, but the user still can cause problems (& vice
versa).

no, not the document, it is an external macro (in soem directory where
word expects 'global' stuff, or maybe in the normal template, or ... I
dunno). The command is:

def WordPrint( FileName ):
  Word = '"C:\\Program Files\\Microsoft Office\\Office10\\WINWORD.EXE"
'
  os.system( Word +  ' ' + FileName + ' ' + '/mPrintDoc '  )

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu


2007\01\26@115952 by Gordon Williams

picon face
You may want to get "Python programming on Win32" by Mark Hammond.  He goes
through exactly the case of using python to create and print out invoices
using Word.  He also does a similar thing but generates PDF invoices.
Lastly he shows how python can be interfaced with excel.

It's a 2000 book so it is a few python versions, ago but still applicable.
You might want to check the python cookbook for ideas.

Regards,

Gordon Williams


{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2007 , 2008 only
- Today
- New search...