Si colocas todos los codigos en un module de excel y abres la pagina del cambio de divisas deberia trabajar sin problemas (en teoria) :-)
Private Declare Function SetForegroundWindow Lib "user32" _
(ByVal hWnd As Long) As Long
Private Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Long
Private Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hWnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long
'Custom structure for passing in the parameters in/out of the hook enumeration function
'Could use global variables instead, but this is nicer :-)
Private Type FindWindowParameters
strTitle As String 'INPUT
hWnd As Long 'OUTPUT
End Type
Public Function FnFindWindowLike(strWindowTitle As String) As Long
'We'll pass a custom structure in as the parameter to store our result...
Dim Parameters As FindWindowParameters
Parameters.strTitle = strWindowTitle ' Input parameter
Call EnumWindows(AddressOf EnumWindowProc, VarPtr(Parameters))
FnFindWindowLike = Parameters.hWnd
End Function
Private Function EnumWindowProc(ByVal hWnd As Long, _
lParam As FindWindowParameters) As Long
Dim strWindowTitle As String
strWindowTitle = Space(260) 'Space(260)
Call GetWindowText(hWnd, strWindowTitle, 260)
strWindowTitle = TrimNull(strWindowTitle) ' Remove extra null terminator
If strWindowTitle Like "*" & lParam.strTitle & "*" Then
lParam.hWnd = hWnd 'Store the result for later.
EnumWindowProc = 0 'This will stop enumerating more windows
Else
EnumWindowProc = 1
End If
End Function
Private Function TrimNull(strNullTerminatedString As String)
Dim lngPos As Long
'Remove unnecessary null terminator
lngPos = InStr(strNullTerminatedString, Chr(0))
If lngPos Then
TrimNull = Left$(strNullTerminatedString, lngPos - 1)
Else
TrimNull = strNullTerminatedString
End If
End Function
Public Sub ExplorerGetNow()
Dim myIE As SHDocVw.InternetExplorer
Dim handleIE As String
Dim IExp As Object
Dim shl, wins, i, winIE, result
Set shl = CreateObject("Shell.Application")
Set wins = shl.Windows
handleIE = FnFindWindowLike("El Universal Currency Converter")
For i = 0 To wins.Count - 1
Set winIE = wins.Item(i)
On error Resume Next
result = winIE.hwnd
If err<>0 then err.clear
If result Like "*" & handleIE & "*" Then
With winIE
Set AmountTB = winIE.Document.getElementsByName("Amount")
If Not AmountTB Is Nothing Then
‘Aqui obtienes informacion del elemento de la webpage
AmountTB(0).Value = "Hola"
End If
‘Do While .Busy Or .ReadyState <> READYSTATE_COMPLETE
‘ DoEvents
‘ Loop
End With
End If
Next
End Sub
