473,756 Members | 6,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autoprint screen (no dialog box to select printer)

1 New Member
Visual Basic 6.3 - i am auto printing a screen using vb. i dont want the print dialog box to appear. the page should just print to the default printer. alternatively if i could use "sendkeys" to dialog box this would be okay but vb code waits for a reply to the print dialog box.. The line I am getting an error on is: application.act ivedocument.pri nt - it jumps to the error handler. I have also tried application.act ivedocument.pri ntform - Note: The application is being made using a process control system which uses VB 6.3 for the GUI, it may be a scaled down version of VB 6.3 - I am not familiar with the printer object, I have tried printer.print but I received an error message saying :variable not defined, I understand what this means, but is the printer object something I can place on the form (like Winsock control) or is it just like a variable that I need to define. I have looked up a few pages on printer object but they havent given me the info i need. Thanks for the help.
Mar 26 '07 #1
1 2750
R Muruganandhan
1 New Member
Function PrintWrapped(By Val strInput As String, Optional bPageBreak As Boolean = False, Optional bBreakWords As Boolean = False) As Integer
' strInput - The string to be printed
' bPageBreak - Set this to true for the
' code to check for end of page,
'and wrap to a new page.
' bBreakWords - Set this to True if you


' do not want to break the line
'at a space if possible (i.e. if you don
't care if it
'breaks words into two pieces)
'
' RETURNS: Number of lines printed. Allo
' ws you to track to end of page
Dim lPointer As Long
Dim lPosition As Long
Dim lPtrWidth As Long
Dim lInputWidth As Long
Dim iLineCount As Integer
Dim strWork As String
lPtrWidth = Printer.ScaleWi dth ' Only check this once
lInputWidth = Printer.TextWid th(strInput)



Do While lInputWidth > lPtrWidth
' Estimate breakpoint
lPosition = Int((lPtrWidth / lInputWidth) * Len(strInput))
strWork = Left$(strInput, lPosition)
' Find max that can print on a line
' First, if you have text that is shorte
' r than the max possible, then
' add additional characters to the work
' string


Do While Printer.TextWid th(strWork) < lPtrWidth
If Len(strWork) = Len(strInput) Then Exit Do
strWork = Left$(strInput, Len(strWork) + 2)
Loop
' Now trim characters off the work strin
' g until it is shorter than
' the printer width


Do While Printer.TextWid th(strWork) > lPtrWidth
strWork = Left$(strWork, Len(strWork) - 1)
Loop
' If you are breaking at spaces, then...
'


If Not bBreakWords Then

lPointer = Len(strWork)
' ************ VB3 - VB5 Code **********
' *****
' If using VB6, then uncomment the line
' of code
' containing th InStrRev function, and c
' omment
' out this code.
' *************** *************** ********
' *****
lPosition = lPointer

' Hunt for a space in the string


Do Until lPosition = 1
If Mid(strWork, lPosition, 1) = " " Then Exit Do
lPosition = lPosition - 1
Loop
' ************* VB6 Code **************
' This line replaces the above block for
' VB6 ONLY
' *************** *************** *******
'lPosition = InStrRev(strWor k, " ", lPoi
' nter)
' ************* End Optional Code
' If there is no space before the first
' character, then we will
' be breaking within a word



If lPosition > 1 Then ' Found a space
strWork = Left(strWork, lPosition - 1)


If lPosition < Len(strInput) Then
strInput = Mid(strInput, lPosition + 1)
Else
strInput = ""
End If
Else ' Must break In word
strInput = Mid(strInput, lPointer + 1)
End If
Else


If Len(strInput) > lPointer Then
strInput = Mid(strInput, lPointer + 1)
Else
strInput = ""
End If
End If
Printer.Print strWork
iLineCount = iLineCount + 1
lInputWidth = Printer.TextWid th(strInput)
' Page break if requested


If bPageBreak Then


If Printer.Current Y > (Printer.ScaleH eight - Printer.TextHei ght(strWork)) Then
Printer.NewPage
End If
End If
Loop



If Len(strInput) > 0 Then
Printer.Print strInput
iLineCount = iLineCount + 1
End If
PrintWrapped = iLineCount
End Function

Private Sub Command1_Click( )
Call PrintWrapped(Tr ue, False)
End Sub
Apr 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1501
by: Dan Kean | last post by:
Hi all, how can I bring a file browser up to select a file then send the path to a textbox and display it (will be image file) also can I limit extensions to *.bmp etc? thanx for any help! Regards Dan
1
1895
by: quest | last post by:
How do I create full screen dialog in C# ? Full screen in the sense that it covers everything on the screen including the tast bar. Thanks.
4
12060
by: MC D | last post by:
What's the best way to have a modal dialog that will only allow the selection of a FOLDER, rather than a file? Is there a property of the openFileDialog I'm missing, or is there another control altogether? I was thinking of doing it from a treeView, but It seems like there ought to be a control for this sort of thing! -D
0
1455
by: hamil | last post by:
I have a graphic file demo program that almost works. My form has a PageSetupDialog, PrintPreview, PrintDialog, and a PrintDocument control. Sample code follows. Now here is the quesion. When I open the PrintDialog control, there is a dropdown to select a printer from the list of available printers. However, the PageSetupDialog sets the properties of the "selected" printer. How do I find and select one of the available printers so I...
2
5714
by: Wayne | last post by:
I'm using the following line of code to print only the first page of a report: DoCmd.PrintOut acPages, 1, 1 This works fine with one limitation. It sends the report to the default printer. Is there some way to show the printer selection window before sending the report to the printer? Any help is appreciated.
3
1475
by: Lloydm | last post by:
I built a timesheet and finally got all my functions working. Iv'e searched through the vb forum but had no luck finding a "print job" script. After saving file and before exit, I would like a script to prompt before exiting Excel to send the job to a printer. If user selects yes then print dialog window shows to select printer, if not do nothing and exit excel. Thanks to all, await a reply
4
4535
by: Ian | last post by:
I have an Access 97 database, on a Report I have the print option set to print to the PC’s default printer rather than a printer selected from the list. My question is: Can I allow the user to change this setting so that by default the report will print to a specific printer that they select rather than the PC’s default printer? The reason for wanting to do this is that I don’t know the names of the printers they might have and the DB...
2
9976
by: Brad Pears | last post by:
I have a vb.net 2005 application and am using the print preview screen. This screen has a printer icon on it that the user can use to print the document currently being viewed. It uses the default printer settings to print. I wanted the print preview to appear the same for all users (i.e. a default page size of 8.5x14 (legal) and portrait mode). Many users have different printers as their default (plotters etc..) and I found that various...
0
1319
by: =?Utf-8?B?VG9t?= | last post by:
I have a number of printers on my home office network, running XP Pro. Two are networked and the other two are parallel port. Everything works, but lately it seems like when I select a printer from the application (MS Word, Excel, etc. and QB 2007) it take forever to load the driver and get itself ready to print. Printing seems normal, but the software set up time seem much longer that before. Any ideas as to what may be going on would...
0
9384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9779
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6473
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5247
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.