Excel Automation with IE - excel

my original question posted
Simulate Double Click Event in IE EXCEL , VBA interaction
.

You said,
this is a deadlocks for me because 1) i trigger the prompt from excel
to retrieve data from server 2) the server is stop responding until
prompt is being dismissed 3) all codes coded to handle prompt not
being processed because excel still waiting for the #1 to complete
I made a tests with some suggestions in older threads, but nothing worked.
References of those older threads.
(1) Disable Alert message of a webpage using VBA code (Refer the second answer)
(2) vba to dismiss an IE8 or IE9 "message from webpage" popup window
The thing is that, VBA code execution get stops when IE display the Alert() message. As code execution is already stopped we are not able to handle the Alert() prompt using code. So user need to close the Alert() prompt manually which resumes the code execution.
For simplicity in testing, if you just try to create an IE object and display the prompt and put some other lines of code after the prompt than you will notice that execution of code get stopped when prompt get displayed and until you close the prompt manually further lines of code will not get execute.
I agree with the suggestion given by the Zhi Lv - MSFT in your referenced thread for using the Selenium Web driver.
It can be the easiest solution for this issue.
References:
(1) Selenium Web Driver
(2) Selenium handle alerts prompts confirmation popups

Related

Allow "Mouse Click" event or "switch Excel tab" when a macro is running

I have a macro that extracts data from Microfocus RUMBA Mainframe Display and puts in Excel rows one after the other. I have created a Global Mainframe object and that is used for extraction to Excel. But when the process is running and if user decides to stop the processing he cannot click on Stop button on Excel or go to different tabs to see the data being pasted. He has to clicks like 6 times before tabs are switched or stopped.
I see that DoEvents allows mouse click events in the loop to do things but the code is written in a way that there is a lot of lines with in the loop and a function with no loop, and placing DoEvents after everyline seems irrational. I have a feeling there is a better to do that but not sure what that is. Can anyone please help?.
VBA is single threaded. So you can't have one VBA action interrupt another. If you had a cancel button, for example, and the user was allowed to click it via a DoEvents processing the cancel action would still run after the currently running procedure.
In Excel this single threaded nature ends up being a good thing because you generally don't want the user interacting with the workbook while you are making programmatic changes. If this was allowed you would get undefined behavior.
Your best course of action would be to make a .NET application that uses the Excel Interop extensions to move the data from the mainframe to Excel. If you use VB.NET then you will find the code is quite similar to VBA. In fact, the Excel.Application object model is identical so the macro code you already have ports cleanly over.
There is an add-in that will help RUMBA development here:
https://www.microfocus.com/documentation/rumba/desktop951/RumbaSystemAdminGuide/GUID-DDB7571D-6167-4F8B-876E-E7450F3030B2.html

What causes this popup in Excel VBA?

I am making a simple tool for my job. It involves opening a file dialog box, selecting a file, opening it, analyzing it for different items, then creating a new workbook with the results. This is all done with VBA macros, activated via a command button.
The code works fine, all does what it's supposed to. However, at the start when the file dialog box is first opened, sometimes this error message pops up:
It doesn't affect the code or how it runs whatsoever, but it is a bit of a nuisance. There is no further detail provided for this "error". Does anyone know what might cause this popup?

how to judge if the use closes the excel file with x button at right upper corner in VBA

My VBA application sometimes is shutdown because of Citrix time-out. And the normal close of the excel file is by clicking X button at the right upper corner.
My question is if VBA can judge the excel file is closed by which method. I need to do the further operations according to the method of closing the excel file. Thanks!
#HackSlash , the excel is put into Citrix environment, which will be time out after 15 minutes. if Citrix is time out, the excel file will be shutdown without saving the content. Some users of the VBA will click the button then go away; when they are back, the excel file is shutdown by Citrix without saving. After the user read through the result of VBA, they will clear the content for the sake of security. So here, the scenario is if the excel is shutdown by Citrix abnormally, I want to save the result of VBA, so that the user can still see the result after they go back; if the excel is closed by clicking X at the right-upper corner, it means that these users has read through the result, all the contents should be cleared for the sake of security. Thanks!
It depends on how Citrix is closing your Excel sessions (I am not familiar with it), but probably, Yes you can tell.
The trick is to catch the QueryClose event and then check the CloseMode parameter. A 0 means that it was closed by clicking the [X] on the windows control menu. Citrix is probably using reason 2 or 3.
However, be forewarned that Citrix may be killing the Excel process in such a way that that this event is not called (though other shutdown events may happen). You'll have to test it to be sure.

Excel - Countdown Message box until Macro is Complete

I have a Macro which takes 45 seconds to complete. When the macro starts I want a Countdown timer to pop up like a message box which will countdown until Macro completion. I have searched but so far cant find any answers to this. Is this possible?
As #Thrum correctly mentioned in his comment this is not possible with a message box.
A MsgBox is modal and therefore blocks the entire Excel application. Nothing else can happen / be done while that message box window is open and waits for you to close it. Actually, you can even make message boxes system-wide modal. In that case no other Windows application will respond unless you close that little message box in Excel (check the option vbSystemModal within the VBA help regarding MsgBox).
However, with forms on the other hand you have a choice. You can make the form not modal.
UserForm1.Show (False)
In that case the code continues to run in the background while the form is shown to the user and permits the running VBA code to make changes to the form while it is shown to the user.

Excel 2007 automatically starts debugger when showing dialog

I have a UserForm and when I display it dlg.Show vbModal excel is entering the debugger. There's no error, it just enters the debugger - like it thinks it has hung. How do I stop it from enter the debugger?
Moving my comment to an answer so that this question doesn't get DELETED automatically.
Reason Why this happens:
For some reason, the VBA project thinks a breakpoint existed within that event script, so the VBA editor stops on that particular line of code, although there is no visible breakpoint seen.
Two ways to solve this problem:
As per THIS MSDN ARTICLE, select the Clear All Breakpoints option under the Debug menu.
If the above doesn't work, then simply re-start your pc. Remember to save your work if applicable.

Resources