Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Word's PrintOut method

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 10-18-2006   #1 (permalink)
Fabio GRANDE poker.it>
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 SpecsSystem Spec
Old 10-18-2006   #2 (permalink)
klumsy@xtra.co.nz
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 SpecsSystem Spec
Old 10-19-2006   #3 (permalink)
Fabio GRANDE poker.it>
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 SpecsSystem Spec
Old 10-19-2006   #4 (permalink)
klumsy@xtra.co.nz
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 SpecsSystem Spec
Old 10-19-2006   #5 (permalink)
Fabio GRANDE poker.it>
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51