[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.9

"Download file" dialog automation

Asked by Pakhu in Automation, Microsoft Excel Spreadsheet Software, Visual Basic Programming, VB Controls

Tags: ie, automation, vb, vba, user32

I'm trying to automate a File download dialog from a web site, using IE automation on VBA.

So far I've succeeded in getting the handle on the dialog window and the control (save button). But i can't click on it, although I've tried (as you can see in the code) several alternatives. The only thing I've get is that the focus shifts from the Cancel to the Save button, but is not properly clicked so I don't get the save as dialog as i get doing manually.

I guess I'm missing something gross here or else I'm being blocked by some kind of security settings (I'm using Vista and IE8)

Thankyou
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
Option Compare Database
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SendNotifyMessage Lib "user32.dll" Alias "SendNotifyMessageA" (ByVal hwnd As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Private Declare Function SetActiveWindow Lib "user32.dll" (ByVal hwnd As Long) As Long
 
Private Const BM_CLICK = &HF5
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDOWN = &H201
Private Const BM_SETSTATE = &HF3
Private Const WM_COMMAND = &H111
Private Const WM_CLOSE = &H10
Private Const WM_KEYDOWN = &H100
Private Const WM_CHAR = &H102
Private Const VK_RETURN = &HD
 
 
 
 
 
Sub GuardarComo()
 
 
Dim r As Long, BtnSave As Long, lngRet As Long
Dim retval As Long
 
r = FindWindow("#32770", "File Download")
 
    If r > 0 Then
        BtnSave = FindWindowEx(r, 0, "Button", "&Save")
 
        If BtnSave > 0 Then
            retval = SetActiveWindow(r)
            
            DoEvents
            SendMessage BtnSave, BM_CLICK, 0, ByVal 0&
            
            DoEvents
            SendNotifyMessage BtnSave, BM_CLICK, 0, vbNullString
            
            'SendMessage BtnSave, WM_LBUTTONDBLCLK, 0, 0
            'SendMessage BtnSave, WM_COMMAND, &H1144, &H10370
            DoEvents
 
            lngRet = SendMessage(BtnSave, BM_CLICK, 0, vbNullString)
            
            'hwnd_button_hexa = Hex(BtnSave)
            'hwnd_hexa = Hex(r)
              
            
            SendMessage BtnSave, BM_CLICK, ByVal CLng(0), ByVal CLng(0)
 
            SendMessage r, VK_RETURN, ByVal CLng(0), ByVal CLng(0)
            
 
        End If
        
        'If BtnSave > 0 Then SendMessage BtnSave, WM_LBUTTONDBLCLK, 0, 0
    End If
End Sub
Related Solutions: "File Download" Automation
[+][-]08/25/09 07:23 AM, ID: 25177892Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/09 07:33 AM, ID: 25178000Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/25/09 08:12 AM, ID: 25178426Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/25/09 08:28 AM, ID: 25178611Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/06/09 04:05 PM, ID: 25510844Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10/06/09 04:05 PM, ID: 25510849Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10/09/09 07:55 PM, ID: 25540581Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]10/09/09 09:04 PM, ID: 25540789Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/12/09 11:56 PM, ID: 25557496Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/16/09 09:58 AM, ID: 25591230Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Automation, Microsoft Excel Spreadsheet Software, Visual Basic Programming, VB Controls
Tags: ie, automation, vb, vba, user32
Sign Up Now!
Solution Provided By: egl1044
Participating Experts: 3
Solution Grade: A
 
[+][-]10/16/09 12:47 PM, ID: 25592701Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/19/09 12:13 AM, ID: 25603067Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625