Solved

Get focus back to Excel

Posted on 2014-11-15
7
92 Views
Last Modified: 2014-11-25
I have an Excel/vba app that is used to place orders at Overstock.  Before the order is placed, a dialog box is generated in Excel asking the user if they want to place the order or not.  You don't see the dialog box, but excel starts flashing.  It you click on Excel, the dialog box appears.  Is there someway to get the focus back to Excel?
0
Comment
Question by:rrhandle8
  • 3
  • 3
7 Comments
 
LVL 81

Expert Comment

by:byundt
ID: 40445294
Please post the code with the problem, or better yet post the workbook.

Which version of Excel are you using?
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40445690
It is intentional that applications cannot bring themselves in front anymore. Instead, they are flashing in taskbar. This is to make sure noone intercepts interactive input for malicious purposes.

However, you can trick that (IIRC) by making the current window minized and then restore it back again. As you seem to trigger the Dialog Box call somehow from outside of Excel, it should not be difficult to change window state first.
0
 

Author Comment

by:rrhandle8
ID: 40445837
Here is the code.
Credit card information is entered into the  web page, then I want the dialog box to ask the user if they want to proceed with the order.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:rrhandle8
ID: 40445838
ieDoc.getElementById("CC").Click
ieDoc.getElementById("CC_number").Value = frmOrderSystem.txtCreditCard
ieDoc.getElementById("exp_month").Value = frmOrderSystem.txtExpMonth
ieDoc.getElementById("exp_year").Value = frmOrderSystem.txtExpYear

Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.READYSTATE = READYSTATE_COMPLETE: DoEvents: Loop
Func.PauseBrowser


If frmOrderSystem.chkPromptBeforePlacingOrder = True Then
    response = MsgBox("Do you want to place this order?" & vbCrLf & "ProfitLoss: " & ProfitLoss, vbYesNo)
Else

Open in new window

0
 
LVL 69

Expert Comment

by:Qlemo
ID: 40445902
There is no way to reasonable do that, if the Web page is shown for confirming it is the correct order to get placed. It only makes sense to either show the msgbox or IE in front, but not both. Unless the resolution is large enough to show both side by side ;-).

If you do need the IE only for executing your login / CC stuff, why not do that invisibly?
0
 

Author Comment

by:rrhandle8
ID: 40459065
Cannot do it invisibly because we need to watch what is going on until we have the bugs work out of it.
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40459348
Try if
Application.WindowState = xlMinimized
Application.WindowState = xlNormal

Open in new window

before line 12 does the job.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question