My Code:
Sub login()
Dim IE As Object
Dim HTMLDoc As Object, HTMLDoc2 As Object, HTMLDoc3 As Object, HTMLDoc4 As Object, HTMLDoc5 As Object
Dim objCollection As Object
Dim intChoice As Integer
Dim strPath As String
Const navOpenInNewTab = &H800
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://www.abcd.com/CWRWeb/displayMemberLogin.do"
...............
Do While IE.Busy Or IE.ReadyState <> 4: Loop
Application.Wait (Now + TimeValue("00:0:03"))
IE.Navigate "https://www.abcd.com/CWRWeb/OnlineStmtResultsPremDis.do" 'Final PDF
Application.Wait (Now + TimeValue("00:0:03"))
Set HTMLDoc5 = IE.document
Application.SendKeys "+^{S}" 'Save Key ShortCut
Application.Wait (Now + TimeValue("00:0:03"))
'Finding the Save As Dialog Box
timeout = Now + TimeValue("00:00:30")
Do
hWnd = FindWindow(vbNullString, "Save As")
DoEvents
Sleep 200
Loop Until hWnd Or Now > timeout
If hWnd Then
hWnd = FindWindowEx(hWnd, 0, "Button", "&Save")
End If
If hWnd Then
SetForegroundWindow (hWnd)
Sleep 600
SendMessage hWnd, BM_CLICK, 0, 0
End If
End Sub
Meine Erklärung in einem anderen Modul ist:Speichern einer PDF nicht möglich .... Klicken Sie im Dialogfeld Speichern unter auf die Schaltfläche Speichern. VBA-Code
Option Explicit
Public Declare PtrSafe Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Public Declare PtrSafe Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
Public Declare PtrSafe Function SendMessage Lib "user32" (ByVal hWnd As LongPtr, ByVal wMsg As Long, _
ByVal wParam As LongPtr, lParam As Any) As LongPtr
Public Declare PtrSafe Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As LongPtr
Public Declare PtrSafe Function SendMessageByString Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As LongPtr
Public Declare PtrSafe Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPtr
Public Declare PtrSafe Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Const BM_CLICK = &HF5
Public Const WM_SETTEXT = &HC
Public Const WM_GETTEXT = &HD
Public Const WM_GETTEXTLENGTH = &HE
Public Const VK_KEYDOWN = &H0
Public Const VK_KEYUP = &H2
Public Const VK_CONTROL = &H11
ich gedebuggt und fand, dass ich bin in der Lage die gleiche Hwnd für Findwindow und FindWindowEx zu bekommen, aber die Sendmessage-Funktion einer Laufzeit gibt error453: Cant DLL Eingangspunkt finden SendMessage in User32
Gibt es eine Möglichkeit auf die Schaltfläche Speichern des SAVEAS Dialogfeld zu klicken? – Shank
Haben Sie die obige Sub/Integration in Ihrem Code ermüdet? Kennst du Sendkeys? Application.SendKeys ({ENTER}) – Sgdva
Der Code gibt einen Fehler für die Deklaration .... meins ist 64-Bit-System. Ich habe sendkey verwendet, um das Dialogfeld "Speichern unter" zu öffnen. – Shank