Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application.SendKeys & Printing

I am having an issue using SendKeys! (I know, I know they are rubbish)
I have a requirement to print to specific trays for a specific worksheet and
I therefore have set up 3 buttons on a sheets:

Labels Only
Band Only
Labels & Band

As i'm sure you all aware Excels abailty to send to a particular tray is
somewhat lacking leaving me two options:

1. Use sendkeys
2. Set up the printer on the network for each tray.

Unfortunately for reasons I shall not go into option 2 is not available so I
am left with the first option.

Here is the code I have (which incidently works very well)

Sub Print_Labels()
'Application.ScreenUpdating = False
Dim laba As Variant
laba = 1
Printing (laba)
End Sub
Sub Print_Wristbands()
'Application.ScreenUpdating = False
Dim laba As Variant
laba = 2
Printing (laba)
End Sub
Sub Print_1Each()
'Application.ScreenUpdating = False
Dim laba As Variant
laba = 3
Printing (laba)
End Sub

Sub Printing(laba As Variant)

'Application.ScreenUpdating = False

Dim y, x, w, v, p, o, sh As Variant

Sheets("Patient Wristbands").Select
Application.ScreenUpdating = False
ActiveSheet.Unprotect

Sheets("Patients").Visible = False
Sheets("Wristbands").Visible = True
Sheets("Labels").Visible = True

Sheets("Patient Wristbands").Range("F1:M500").ClearContents
Sheets("Patient Wristbands").Range("G2").Value = "The following
LaserBand wristbands have been successfully printed."
Sheets("Patient Wristbands").Range("G15").Value = "If there is a problem
with this report please contact "

Sheets("Patient Wristbands").Columns("E:R").EntireColumn.Hidden = False

Select Case laba
Case 1 'Print Labels Only
sh = ("Labels")
Sheets(sh).Select
label_printing
Case 2 'Print Wristbands Only
sh = ("Wristbands")
Sheets(sh).Select
wristband_printing
Case 3 'Print 1 Label, 1 Wristband
sh = ("Wristbands")
Sheets(sh).Select
label_printing
wristband_printing
End Select

End Sub
Sub label_printing()
Sheets("Labels").Select
Application.SendKeys "%FP%R+^{PGDN}{TAB 3}{UP 10}{DOWN
10}{UP}~%R+^{PGUP}~~", True
End Sub
Sub wristband_printing()
Sheets("Wristbands").Select
Application.SendKeys "%FP%R+^{PGDN}{TAB 3}{UP 10}{DOWN 10}~%R+^{PGUP}~~", True
End Sub

Now Case 1 & 2 are great and run off as expected however Case 3 will only
print the label and halt (without error) after completing that!

Also if I add any code after the Case Select then the pages do not print
either (again without error!)

I do not understand why this would happen as just running the send keys
works fine, and running just the send keys within the Case is fine also.

I need the code to run within a do until as I would like it to run multiple
prints at once!

Any help would be gratefully received!

Thanks
Dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Application.SendKeys & Printing

Hi Vba,

Now Case 1 & 2 are great and run off as expected however Case 3 will only
print the label and halt (without error) after completing that!

Also if I add any code after the Case Select then the pages do not print
either (again without error!)


Try adding DoEvents immediately after the sendkeys command.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application.SendKeys & Printing

No joy I'm afraid - exact same results!

"Jan Karel Pieterse" wrote:

Hi Vba,

Now Case 1 & 2 are great and run off as expected however Case 3 will only
print the label and halt (without error) after completing that!

Also if I add any code after the Case Select then the pages do not print
either (again without error!)


Try adding DoEvents immediately after the sendkeys command.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default Application.SendKeys & Printing

Hi Vba,

No joy I'm afraid - exact same results!


In that case I'm out of idea's. SENDKEYS is impossible to troubleshoot when you
do not have the same setup unfortunately. Keep trying, maybe you've missed a
key or two in the problem one. Sometimes it helps to change the way you access
the property you need using the keyboard (use a different sequence I mean).

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

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
SendKeys to open application Arne Hegefors Excel Programming 4 August 15th 06 09:37 AM
Close an application with sendkeys ina Excel Programming 2 May 16th 06 08:15 AM
The application SendKeys Jim333[_6_] Excel Programming 2 August 17th 05 05:44 AM
SendKeys and Application.ScreenUpdating Michael Malinsky[_2_] Excel Programming 3 March 23rd 05 10:40 PM
Application.sendkeys Adrie Rahanra Excel Programming 1 October 15th 03 04:29 PM


All times are GMT +1. The time now is 09:54 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"