However, if your default printer is attached to the LPT1 (or another
local port) you may be able to send simple, unformatted output to the
printer by opening that port and writing to it. For example, ...
with createobject("scripting.filesystemobject")
set printer = .opentextfile("LPT1",2)
For i = 0 To 1000 Step 100
Printer.WriteLine i
Next
end with
Newer printers may not support this and the output will be ugly.
Another common is to write the data to a temporary file and then use
notepad to send the data to the printer, as in ...
const wait = true
hideWindow = 0
tempName = "tempfile.txt"
with createobject("scripting.filesystemobject")
set tempfile = .opentextfile(tempName,2)
For i = 0 To 1000 Step 100
tempfile.WriteLine i
Next
tempfile.close
createobject(wscript.shell").run "notepad /p " &
"tempfile.txt",hideWindow ,Wait
tempfile. delete
end with
There are other techniques documented - try a google.groups search of
this group or better yet "microsoft.public.scripting.*".
Tom Lavedas
=============
http://members.cox.net/tglbatch/wsh
If you have a (vb) compiler available, it is a simple
matter to write an actX object which will pass the
visual basic printer object across to your script.
In fact here is some (air) code:
Dim m_Printer As Printer ' (at module level)
Public Property Get vbPrinterObject() As Object
' select a printer (in this case the default printer)...
Set m_Printer = Printer
' pass the default printer back to vbs...
Set vbPrinterObject = m_Printer
End Property
Thanks to the magic of com interfaces you can exercise
_most_ of the printer methods and properties directly
from script (i.e., without writing separate interfaces
for them).
Unfortunately, the one you asked about, i.e., the "Line"
method is not one that can be accessed directly from
script. The reason is that the parameters are "non-
standard", those crazy parentheses which are part of
the parameters, and which will cause vbs to throw up
when it sees them.
And so, "line" will need to be "wrapped":
Public Sub DrawLine(X1 As Variant, Y1 As Variant, _
X2 As Variant, Y2 As Variant)
m_Printer.Line (CSng(X1), CSng(Y1))-(CSng(X2), CSng(Y2))
End Sub
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
Create your text in a hidden MSWord window and print it.
set oWord=createobject("word.application")
' Costanti di word per l'allineamento del testo.
const wdAlignParagraphCenter=1
const wdAlignParagraphLeft=0
const wdAlignParagraphRight=2
const wdAlignParagraphJustify=3
with oWord
.documents.add
.Selection.Font.Name = "Arial"
.Selection.Font.Size = 20
.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Selection.TypeText "Title"
.Selection.TypeParagraph
.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
.Selection.Font.Name = "Garamond"
.Selection.Font.Size = 12
.Selection.TypeText "asfasdfasdfasdfasdf"
.Selection.TypeParagraph
.Selection.TypeText "asfasdfasdfasdfasdf"
.Selection.TypeParagraph
.Application.PrintOut
'.ChangeFileOpenDirectory "c:\data"
'.ActiveDocument.SaveAs "temp.doc"
'.ActiveDocument.Close
end with
wscript.quit
--
Giovanni Cenati (Aosta, Italy)
Write to user "Reventlov" and domain at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--