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!

Macro that Prints address lables

Status
Not open for further replies.

0wned

Technical User
Jul 27, 2004
5
US
Hey, Im trying to make a macro that grabs a address off the screen and prints it on a postcard. I snaged a wonderfull little script off the forums and made a few modifications, and its almost perfect! I have two problems though:

1. The macro is made to print to a network printer, I would like to have it print to the local default printer.

2. I need it to print "Landscape" as aposed to "Portrate" which is the default..

Thanks in advance,

Jon

Here's the code:

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

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 = 100 ' 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)

' This section of code contains the recorded events
Dim rc%
Dim MaxColumn%
Dim row%
Dim MaxRows%
Dim filenum%
Dim Screenbuf$
Dim linebuf$
Dim FileName$


FileIn=FreeFile
'Grabs the address and stores it in variable Screenbuf$
Screenbuf$=" "+Chr$(13)+Chr$(10)+Chr$(13)+Chr$(10)+Chr$(13)+Chr$(10)+Chr$(13)+Chr$(10)+Chr$(13)+Chr$(10)
linebuf$=Space$(33)
For row%=2 to 6
linebuf$=Sess0.Screen.Area(row%,1,row%,33,xBlock)
Screenbuf$=Screenbuf$+" "+linebuf$+Chr$(13)+Chr$(10)
Next

filenum%=Freefile
FileName$="\\W08084ZB340\HPLaserJ5" 'name of your network printer
Open FileName$ For Output as filenum%
Print # filenum%,screenbuf$; chr$(12) 'this actually sends the screen print to the printer
Close filenum%

System.TimeoutValue = OldSystemTimeout
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top