ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Close Dialog Box with SendKeys (https://www.excelbanter.com/excel-programming/312328-close-dialog-box-sendkeys.html)

Jim May

Close Dialog Box with SendKeys
 
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,,



keepITcool

Close Dialog Box with SendKeys
 
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


"Jim May" wrote:

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,,





Jim May

Close Dialog Box with SendKeys
 
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

keepITcool

Close Dialog Box with SendKeys
 
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


Jim May wrote:

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com