> -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu] On Behalf Of Wouter van Ooijen > Sent: Friday, 26 January 2007 10:02 PM > To: 'Microcontroller discussion list - Public.' > Subject: RE: [EE] Open word doc and print 3 times script,was: > Taking the funout of computers -WindowsVistaContentProtection > > > 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. 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: http://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 -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist