Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
members on my network printer not able to print to default printer | Excel Discussion (Misc queries) | |||
Printer Multiple Worksheets with a particular Printer Setting | Excel Worksheet Functions | |||
How do I send a spreadsheet to a printer outside the network? | Excel Discussion (Misc queries) | |||
Printer Set Up in VBA | Excel Programming | |||
Sending print commands to the printer | Excel Programming |