Click here to Skip to main content
15,917,538 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
click-ok excelfile dialogbox through programming.

[EDIT]
i want password recovery of excel vba .i did half of recovery process .But when i am opening excel vba file after opening that showing a dialogbox that i have to click ok .So that i am asking how to click it ok through code because i have to do it through code only .Manually its easy .
[/EDIT]

What I have tried:

please help for excel file dialog box click
Posted
Updated 2-Apr-18 21:53pm
v2
Comments
Afzaal Ahmad Zeeshan 1-Apr-18 9:39am    
Are you showing the dialog where you need to press Ok, or do you want to press Ok on someone else's dialog in this?
Dave Kreskowiak 1-Apr-18 10:50am    
That depends on what the dialog is saying, where the dialog is coming from, and what you're code is written in (VBA in Excel, external C# or VB.NET code, ...), none of which you explained.
gelsmith 2-Apr-18 5:05am    
i have did most of work for vba password recovery .But when i am manually opening excel vba that time it showing a dialog box that i have to click ok through code how can i do .
Dave Kreskowiak 2-Apr-18 8:44am    
You can't. Not from Excel VBA code. Your code is stopped while the dialog box is open.

If you're trying to brute force guess the password by trying every combination of letters and numbers, you're going to be there for a VERY LONG TIME. Trying to open the Excel sheet and guessing the password on just a single workbook may very well exceed your lifetime. The problem there is you're introducing the overhead time of opening Excel and telling it to open the workbook.

Your approach to "cracking", not "recovering", the password is naive at best.
gelsmith 2-Apr-18 5:05am    
through excel automation code can you help me

Quote:
click-ok excelfile dialogbox through programming.

Short answer: you don't.
Basically, your mystery dialogbox, just like any excel dialogbox, is modal, this mean that vba is stopped as long as the dialogbox is waiting for an answer. Thus it prevent vba from automating the dialogbox.
 
Share this answer
 
Comments
Maciej Los 2-Apr-18 13:42pm    
5ed!
Patrice T 2-Apr-18 15:32pm    
Thank you
According to the documentation, a Workbooks.Open Method (Excel)[^] gets several parameters. One of them is a Password.
Quote:
A string that contains the password required to open a protected workbook. If this argument is omitted and the workbook requires a password, the user is prompted for the password.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900