I'm using the following Extra Basic code to attempt to send a screen scrape to a local network printer for printing.
Can anyone give some pointers in VBS as to how this could be done? There's not much EB help out there but i've been lucky so far in converting most VBS samples to work in EB with a few minor changes.
Can anyone give some pointers in VBS as to how this could be done? There's not much EB help out there but i've been lucky so far in converting most VBS samples to work in EB with a few minor changes.
Code:
Global Sys As Object, Sess As Object, MySess As Object
'Global WshNetwork as Object,oPrinters as object, wshshell as object
Sub Main
'Set WshNetwork = CreateObject("WScript.Network")
'set WshShell = CreateObject("WScript.Shell")
'Set oPrinters = WshNetwork.EnumPrinterConnections
'For i = 0 to oPrinters.Count - 1 Step 2
'msgbox oPrinters.Item(i+1)
'Next
'using this to see what printers are available
'still not sure how to tell which one is the default printer
Dim rc%
Dim MaxColumn%
Dim row%
Dim MaxRows%
Dim filenum%
Dim Screenbuf$
Dim linebuf$
Dim FileName$
' Get the necessary Session Object
Set Sys = CreateObject("ACCMGR.System")
Set Sess = Sys.ActiveSession
Set MySess = Sess.screen
If (Sess is Nothing) Then
Msgbox "Could not create the Session object."
STOP
End If
If Not Sess.Visible Then Sess.Visible = TRUE
Sess.Screen.WaitHostQuiet(g_HostSettleTime)
FileIn=FreeFile
MaxRows%=MySess.Rows()
MaxColumns%=MySess.Cols()
Screenbuf$=""
'Takes a "snapshot" of screen and stores it in variable Screenbuf$
For row%=1 to MaxRows%
Screenbuf$=Screenbuf$+MySess.getstring(row%,1,MaxColumns%)+Chr$(13)+Chr$(10)
Next
filenum%=Freefile
FileName$="FRC014p2584417" 'name of your network printer
Open FileName$ For Output as filenum%
Print # filenum%,screenbuf$; chr$(12) 'supposed to send the scrape to printer
Close filenum%
End Sub