Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Send printer escape commands to a printer using VBA


Is there a way to send a printer escape command to a printer via VBA?

For example, in Lotus 123 we could put ||\027&l1O in the 1st cell of a
spreadsheet which would set the printer to landscape mode.

Thanks for everyones help! mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=473633

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Send printer escape commands to a printer using VBA

Maybe....

Option Explicit
Sub testme01()
Open "LPT1:" For Output As #1
Print #1, "yourstringhere"
Close #1
End Sub

But why not just page to landscape using file|page setup. If you need a macro,
you can record a macro when you do it manually.



mikeburg wrote:

Is there a way to send a printer escape command to a printer via VBA?

For example, in Lotus 123 we could put ||\027&l1O in the 1st cell of a
spreadsheet which would set the printer to landscape mode.

Thanks for everyones help! mikeburg

--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=473633


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Send printer escape commands to a printer using VBA


The problem I am trying to solve is that my HPIIIsi printer is set to
default of 6.5 lines per inch. In Lotus 123, I put an escape comman
of ||\027 &l6D in the 1st cell that set the printer to 6 lines pe
inch. I am having trouble doing that in Excel.

The above code works great when modified as follows:

Sub testme01()
Open "LPT1:" For Output As #1
Print #1, Chr(27) + "&l6D" '(6lpi works!)
Print #1, "This is a test"
Print #1, Chr(12) '(FormFeed works!)
Close #1
End Sub

But I can't get it to print the active worksheet. When I run the abov
code then print the worksheet, I still get 6.5 lines per inch (it'
reset back to it's default). I get the same problem when I put it i
the before print event too.

It's important that I be able to set the print command to 6 lines pe
inch when printing labels & other forms on that particular printer.

Any suggestions? mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=47363

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Send printer escape commands to a printer using VBA

First, I don't think I'd use Excel to print labels. I'd use excel to hold my
data, but I'd use all the stuff built into MSWord to print the labels.

MSWord has a nice way to merge data from excel file:

http://www.mvps.org/dmcritchie/excel/mailmerg.htm
http://www.mvps.org/word/FAQs/MailMerge

The first is from David McRitchie and the second is by Beth Melton and Dave
Rado.

And MSWord has lots of support for standard sized labels. Just way more options
that you'd ever think!

And second, if I had to print labels through excel and also send the escape
characters to the printer, then I'd use that same technique for sending the data
to the printer.

Untested!

Sub testme01()
dim myCell as range
dim myRng as range
with activesheet
set myrng = .range("a1",.cells(.rows.count,"A").end(xlup))
end with

Open "LPT1:" For Output As #1
Print #1, Chr(27) + "&l6D" '(6lpi works!)

for each mycell in myrng.cells
Print #1, mycell.value & "--" & mycell.offset(0,1).value
Print #1, mycell.offset(0,2).value & "--" & mycell.offset(0,3).value
print #1
next mycell

Print #1, Chr(12) '(FormFeed works!) 'I'd hit the button!
Close #1
End Sub

But seriously, take a look at MSWord and printing labels from there. You'll be
pleasantly surprised.



mikeburg wrote:

The problem I am trying to solve is that my HPIIIsi printer is set to a
default of 6.5 lines per inch. In Lotus 123, I put an escape command
of ||\027 &l6D in the 1st cell that set the printer to 6 lines per
inch. I am having trouble doing that in Excel.

The above code works great when modified as follows:

Sub testme01()
Open "LPT1:" For Output As #1
Print #1, Chr(27) + "&l6D" '(6lpi works!)
Print #1, "This is a test"
Print #1, Chr(12) '(FormFeed works!)
Close #1
End Sub

But I can't get it to print the active worksheet. When I run the above
code then print the worksheet, I still get 6.5 lines per inch (it's
reset back to it's default). I get the same problem when I put it in
the before print event too.

It's important that I be able to set the print command to 6 lines per
inch when printing labels & other forms on that particular printer.

Any suggestions? mikeburg

--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=473633


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
members on my network printer not able to print to default printer smeheut Excel Discussion (Misc queries) 0 June 18th 07 06:42 PM
Printer Multiple Worksheets with a particular Printer Setting PP[_2_] Excel Worksheet Functions 0 March 14th 07 02:02 PM
How do I send a spreadsheet to a printer outside the network? Moe in Goffstown Excel Discussion (Misc queries) 3 February 14th 07 04:34 PM
Printer Set Up in VBA PostalVote Excel Programming 3 July 29th 04 12:29 PM
Sending print commands to the printer Brady Snow Excel Programming 1 November 3rd 03 11:41 PM


All times are GMT +1. The time now is 04:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"