Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

screen to printer

Status
Not open for further replies.

braven

Programmer
May 20, 2009
58
CA
thanks for your all help. i am tryting to do from screens to printer.
i copied the code from this website and modified little bit. it is not printing anything. blank paper only. could yo help me please!!!!


Sub Main()
'-----------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System")
' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'-----------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 3000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' Initialize Screen Buffer
screenbuf$ = ""

' Initialize screenNumber%
screenNumber% = 0

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' Determine the size of the Presentation Space
MaxRows% = Sess0.Screen.Rows()
MaxColumns% = Sess0.Screen.Cols()

' Initialize variables to hold screen information
linebuf$ = Space$ (MaxColumns%)

' Add a line identifying this as a pricing request
linebuf$ = "Example Report Name"
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)
linebuf$ = ""
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)

' Copy the Presentation space
For row% = 1 to MaxRows%
' Get a row of data from the host screen
linebuf$ = Sess0.Screen.Area(row%, 1, row%, MaxColumns%, , xBlock)

' Store the line read into screenbuf$
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)
Next
PrintScr
' Add a blank line after the screen for readability
linebuf$ = ""
screenbuf$ = screenbuf$ + linebuf$ + Chr$ (13) + Chr$ (10)

PrintScr
' Increment the screen number
Sess0.Screen.Sendkeys("<Enter>")

screenNumber% = screenNumber% + 1
System.TimeoutValue = OldSystemTimeout
End Sub

Sub PrintScr

' Get the next available file number
filenum% = FreeFile
FileName$ = "\\wcakt-p3-prn09\HP81500"

' Open the printer. To print to a file, set FileName$ to a file name.
'' Change this to your printer name.

FileName$ = "c:\test.txt"
Open FileName$ For Output as filenum%

' Print the screen with a form feed
Print # filenum%, screenbuf$; Chr$ (12)

'Close printer
Close filenum%

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top