|
-
July 10th, 2001, 12:34 PM
#1
Simulating keyboard input.
Greetings,
Is there a way to bring up the Excel 2000 (9.0) Print Dialog box using VBA code or simulate the keyboard keystrokes of (Alt+F & Ctrl+P) that could be called with a command button? I've got an Excel VBA application, using Microsoft Common Dialog Control 6.0, that worked before we got a new printer network. Excel's Print Dialog does work with my application and the new network, but I'd like to bring it up with a command button.
Thanks,
Ken
-
July 10th, 2001, 02:32 PM
#2
Re: Simulating keyboard input.
You can use the SendKeys command to send keys to the active window.
SendKeys "%F", false ' sends ctlr + F
I don't know the sign for ALT, but a quick look in the help file should clear that out.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
July 10th, 2001, 02:55 PM
#3
Re: Simulating keyboard input.
SendKeys "%F" 'Sends ALT+F
SendKeys "^F" 'Sends CTRL+F
SendKeys "+F" 'Sends SHIFT+F
Regards,
Michi
MCSE, MCDBA
-
July 10th, 2001, 04:50 PM
#4
Re: Simulating keyboard input.
Thanks for the replies, however, it doesn't' work the way I was hopping for (nothing too unusual about that). I can get the File menu to drop down (ALT+F), but no action on the next SendKeys "^P",False. Again, what I'm really after is direct access to Excel's Print Dialog Box.
Thanks,
Ken
-
July 10th, 2001, 08:31 PM
#5
Re: Simulating keyboard input.
Do not SendKeys Alt+F, Only use
SendKeys "^P"
-
July 11th, 2001, 08:37 AM
#6
Re: Simulating keyboard input.
Ctrl+P does work, from the keyboard. What I've got is a form with the command button over the worksheet I'm working on. When I click the command button, calling the sub with other code and SendKeys "^P", False, the form still has the focus. I get the mouse hourglass (only over the form), but no Excel Print Dialog Box. It seem as if I need to set the focus back to the worksheet, before SendKeys. Anyone know how to do this? I can't find any method in my books that does this (so far).
Thanks,
Ken
-
July 12th, 2001, 12:48 PM
#7
Re: Simulating keyboard input.
A slight variation is what worked - SendKeys "{^}P", False
Thanks,
Ken
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|