![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Word's PrintOut method Hi all. I'm in trouble with Word's PrintOut method. I can open/print/close Word Documents : $wd = new-object -com word.application $wd.visible = 1 $doc = $wd.documents.open("c:\xyz.doc") $doc.printout() $doc.close() I need to print those docs on a file, so I guess that I should pass parameters to the PrintOut method... But How I can do that ?!?!?!?! I don't know the syntax to do it ! (actually, this script print the document on the deault printer...) Someone can point me in the right direction, please ? TIA FabioG |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Word's PrintOut method $doc | get-Member print* shows the members of doc object starting with print so you can see the parameters you need and since the definitions re long you want want to format-list so you can see the whole definition i.e $doc | get-Member print* |Select-Object definition| format-list gives you.. Definition : System.Void PrintOut(Object& Background, Object& Append, Object& Range, Object& OutputFileName, Object& From, Object& To, Object& Item, Object& Copies, Object& Pages, Object& PageType, Object& PrintToFile, Object& Collate, Object& ActivePrinterMacGX, Object& ManualDuplexPrint, Object& PrintZoomColumn, Obj ect& PrintZoomRow, Object& PrintZoomPaperWidth, Object& PrintZoomPaperHeight) Definition : System.Void PrintOut2000(Object& Background, Object& Append, Object& Range, Object& OutputFileName, Object& From, Object& To, Object& Item, Object& Copies, Object& Pages, Object& PageType, Object& PrintToFile, Object& Collate, Object& ActivePrinterMacGX, Object& ManualDuplexPrint, Object& PrintZoomColumn, Object& PrintZoomRow, Object& PrintZoomPaperWidth, Object& PrintZoomPaperHeight) Definition : System.Void PrintOutOld(Object& Background, Object& Append, Object& Range, Object& OutputFileName, Object& From, Object& To, Object& Item, Object& Copies, Object& Pages, Object& PageType, Object& PrintToFile, Object& Collate, Object& ActivePrinterMacGX, Object& ManualDuplexPrint) Definition : System.Void PrintPreview() Definition : System.Boolean PrintFormsData {get;set;} Definition : System.Boolean PrintFractionalWidths {get;set;} Definition : System.Boolean PrintPostScriptOverText {get;set;} Definition : System.Boolean PrintRevisions {get;set;} take your pick |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Word's PrintOut method Thank You for Your answer, but I already knew methods and parameters. I don't know how to use them. For instance, let's take this declaration : > Definition : System.Void PrintOut(Object& Background, Object& Append, > Object& Range, Object& OutputFileName, Object& From, Object& To, > Object& Item, Object& Copies, Object& Pages, Object& PageType, Object& > PrintToFile, Object& Collate, Object& ActivePrinterMacGX, Object& > ManualDuplexPrint, Object& PrintZoomColumn, Obj > ect& PrintZoomRow, Object& PrintZoomPaperWidth, Object& > PrintZoomPaperHeight) In my previous sample, I called PrintOut without parameters.. But what if I would specify the OutputFileName parameter ? I tried : $doc.PrintOut($null, $null, $null, "c:xyz.prn") But I got the error : Argument: '1' should be a System.Management.Automation.PSReference. Please use [ref]. At line:6 char:16 + $doc.printout( <<<< $null,$null,$null,"c:temp.xyz") What does it means "use [ref]" ? I tried : $doc.printout([ref]$null,[ref]$null,[ref]$null,[ref]"c:temp.xyz") But now I got the error : Exception calling "PrintOut" with "18" argument(s): "The number must be between -32765 and 32767." At line:6 char:16 + $doc.printout( <<<< [ref]$null,[ref]$null,[ref]$null,[ref]"c:temp.xyz") I saw that those parameters are defined as "optional"... Should I specify ALL the parameters ? Do You think that $null value could mean "do what You want" ? Or, maybe, I have to load local variables ($a, $b, $c) and use them as parameters ? I'm really in trouble, and the standard documentation doesn't help me too much... TIA Fabio G |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Word's PrintOut method this is a common issue when calling com objects that require a reference.. even if its just null, you gotta make a reference.. i haven't tested this but it should be something like this $a = $null $outfile = "c:temp.xyz" $doc.printout([ref]$a,[ref]$a,[ref]$a,[ref]$outfile) |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Word's PrintOut method Thank You, I did it ! But FYI, the PrintOut method don't like null parameters... $pCopies = 1 $pBackGround = 0 $pAppend = 0 $pRange = 0 $doc.printout([ref]$pBackGround, [ref]$pAppend, [ref]$pRange, [ref]$FilePS) I discovered that I MUST give values for ALL the parameters that comes before the one I need to use (Filename...). Thank You FabioG |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| method not many | USER | Vista mail | 0 | 06-25-2008 05:51 AM |
| Windows Calendar Monthly Display/Printout | Jennifer | Vista General | 5 | 04-13-2008 05:19 PM |
| Method invocation failed because [System.String] doesn't contain a method | B Williams | PowerShell | 0 | 03-31-2008 06:00 PM |
| Printout | Zygy | Vista print fax & scan | 1 | 11-08-2007 09:47 AM |
| Chess Titans Game Printout | ripvw1943 | Vista Games | 9 | 06-24-2007 04:06 PM |