Click to See Complete Forum and Search --> : Simulating keyboard input.


Spudwise
July 10th, 2001, 12:34 PM
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

Cakkie
July 10th, 2001, 02:32 PM
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
slisse@planetinternet.be

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

michi
July 10th, 2001, 02:55 PM
SendKeys "%F" 'Sends ALT+F
SendKeys "^F" 'Sends CTRL+F
SendKeys "+F" 'Sends SHIFT+F


Regards,

Michi
MCSE, MCDBA

Spudwise
July 10th, 2001, 04:50 PM
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

shree
July 10th, 2001, 08:31 PM
Do not SendKeys Alt+F, Only use

SendKeys "^P"

Spudwise
July 11th, 2001, 08:37 AM
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

Spudwise
July 12th, 2001, 12:48 PM
A slight variation is what worked - SendKeys "{^}P", False
Thanks,
Ken