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!

extra print error, print macro question?

Status
Not open for further replies.

mizsydney

Technical User
May 5, 2005
33
US
I was trying to use the print macro suggested here (thread99-575428), but the screen print adds line feeds at the top of the page that aren't there when you print from the toolbar or File>Print Screen. we need the print screen to line up on a preprinted form, so this code won't work for this purpose as is.

I don't see any obvious line feeds in the macro code, at least not for the top of the page.

is there any way around this? this seemed like a great fix for the print error issue, at least until I noticed the extra line feeds.
 
curious,

what happens if you switch linebuf$=Space$(MaxColumns%)
with linebuf$ = "" ???
 
thanks mgwils -

but it didn't seem to make any difference in the print. there are still extra line feeds at the top of the page.

thanks for trying! I'm stumped.
 
My apologies as I can't test this code (My network doesn't allow the permissions nessesary to call the printer in this manner). Give the code below a try and keep your fingers crossed :)
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
 
thanks mgwils!

unfortunately, your code wouldn't run at all on my machine, "too many compiliation errors"... I'm still debugging and hoping this will help.

I do really appreciate your help!
 
Your probably using an Extra session. I originally worked this out for an ACCMGR (older than dirt) session. The problems your getting are due to the sys and sess objects.

Global Sys As Object, Sess As Object, MySess As Object
Set Sys = CreateObject("ACCMGR.System")
Set Sess = Sys.ActiveSession
Set MySess = Sess.screen

try replacing above lines with

Global Sys As Object, Sess As Object, MyScreen As Object
Set Sys = CreateObject("EXTRA.System") 'Assumes an open sessions
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top