?
Solved

[ActiveX] send a string directly to the printer

Posted on 2003-02-26
6
Medium Priority
?
238 Views
Last Modified: 2010-04-07
Greetings,

is it possible to send a string to printer connected to the system drectly via activeX without getting a dialog window?

regards,
Paul K.
0
Comment
Question by:poffel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Expert Comment

by:brebbel
ID: 8025857
Paul,

You don't need ActiveX for this problem.
Visual Basic has a nice way for printing which is very easy.

Below is a simple code example, you can also set font and stuff like that, just take a look at the rest of the properties and methods of the printer object.
Just try teh sample code, and you'll see it works!

Code Example:

Private Sub Command1_Click()
 With Printer
  .CurrentX = 150    ' set X position on paper
  .CurrentY = 150    ' set Y position on paper
  .Line = "Testing"  ' first line page1
  .Line = "Testing"  ' second line page1
  .NewPage           ' Next page
  .CurrentX = 150    ' set X position on paper
  .CurrentY = 150    ' set Y position on paper
  .Line = "Testing"  ' first line page2
  .Line = "Testing"  ' second line page2
  .EndDoc            ' end document, stop printing
 End With
End Sub



Good Luck!!

Brebbel
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8025891
Printer.Print "my string"
this would send it to default printer.
0
 

Expert Comment

by:brebbel
ID: 8025913
Sorry, my mistake, just ignore my first comment
Printer.Line is a funtion for drawing a line, not printing text.

It should be this:

-------------

Private Sub Command1_Click()
 With Printer
  .CurrentX = 150    ' set X position on paper
  .CurrentY = 150    ' set Y position on paper
  .Print "Testing 1" ' first line page1
  .Print "Testing 2" ' second line page1
  .NewPage           ' Next page
  .CurrentX = 150    ' set X position on paper
  .CurrentY = 150    ' set Y position on paper
  .Print "Testing 3" ' first line page2
  .Print "Testing 4" ' second line page2
  .Print
  .EndDoc            ' end document, stop printing
 End With
End Sub


----------
Berry
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Accepted Solution

by:
brebbel earned 100 total points
ID: 8025955
I tried the code at home (no visual basic when i wrote the comment) and it did NOT work. I fixed it so this is WORKING code:

Private Sub Command1_Click()
 With Printer
  .CurrentX = 150    ' set X position on paper
  .CurrentY = 150    ' set Y position on paper
  Printer.Print "Testing 1" ' first line page1
  Printer.Print "Testing 2" ' second line page1
  .NewPage           ' Next page
  .CurrentX = 150    ' set X position on paper
  .CurrentY = 150    ' set Y position on paper
  Printer.Print "Testing 3" ' first line page2
  Printer.Print "Testing 4" ' second line page2
  .EndDoc            ' end document, stop printing
 End With
End Sub


Brebbel

0
 

Expert Comment

by:CleanupPing
ID: 8901072
poffel:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8973026
poffel, an EE Moderator will delete this for you.
Moderator, my recommended disposition is:

    DELETE this question (refund points).

DanRollins -- EE database cleanup volunteer
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question