Close Dialog Box with SendKeys

J

Jim May

at the end of my code using a bunch of SendKeys commands
I'm trying to close a dialog box using:

SendKeys "{Enter}"

and it's not working; any ideas?

TIA,,
 
K

keepITcool

Jim,

any window can be closed with AltF4.. (unless closebox is disabled)

Application.SendKeys "%{F4}"
Application.Dialogs(xlDialogActiveCellFont).Show


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
J

Jim May

It's still not working;
What does line two do?
Line 2: Application.Dialogs(xlDialogActiveCellFont).Show

Here is code at last attempt:

Sub ToggleSavePreviewPicture()
' Sends ALT+F to open the File menu.
SendKeys ("%f"), True
' Sends ALT+I to open the Properties dialog box and displays the
' Summary tab.
SendKeys ("i"), False
' Selects the Save Preview Picture check box.
SendKeys ("%v"), True
' Close Dialog Box
SendKeys ("%{F4}")
End Sub

Jim May
 
K

keepITcool

the 2nd line was an example of how to use sendkeys
with a "dummy" dialog.

(normally you use sendkeys BEFORE opening the dialog..
Jim,

I can see what you want to do..
BUT I dont know an alternative approach to setting that value.
AND SENDKEYS is doomed to fail...

Just open that dialog yourself.
Select the 3rd tab.
Close the dialog.

Open the Dialog again..

See?... It's still on the 3rd tab.. but there's no way (without api's) to
tell which Tab is active. and the Tabs themselves have no accelerator...

Also IF the checkbox was already checked, your code will uncheck it..

FAIK the only alternative is complex code with API's to trap the dialog,
read the settings of the SysTabControl32 object.. etc etc.





keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top