Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

[ActiveX] send a string directly to the printer

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
poffel
Asked:
poffel
1 Solution
 
brebbelCommented:
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
 
Richie_SimonettiIT OperationsCommented:
Printer.Print "my string"
this would send it to default printer.
0
 
brebbelCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
brebbelCommented:
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
 
CleanupPingCommented:
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
 
DanRollinsCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now