Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88150

¿Cómo puedo manipular una ventana emergente con VBA?

$
0
0

tengo un código, que abre una pagina web, rellena el formulario y da clic a los botones necesarios todo funciona correctamente, el problema es que al dar el ultimo clic el resultado se muestra en una segunda ventana, y necesito trabajar con esta segunda ventana para importar los datos a excel y también guardar el archivo como PDF.

Pregunta general, como intercepto y manipulo la ventana emergente. encontré artículos parecidos sin éxito.


Sub Extraerdatos()
Dim IE As Object
Dim MiCombo As Object
Dim c As Long, UltimaFila As Long
Dim Celda As Range

Const OLECMDID_PRINT = 6
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Const PRINT_WAITFORCOMPLETION = 2

Set IE = CreateObject("InternetExplorer.Application")
Let UltimaFila = Cells(Rows.Count, 1).End(xlUp).Row
IE.Visible = True
IE.Navigate2 "http://srv.redinservsa.com/busquedaClienteGeneral.php"

Do While IE.readyState <> READYSTATE_COMPLETE
    DoEvents
Loop
For Each Celda In Range("A2:A"& UltimaFila)

With IE
Set MiCombo = IE.Document.all("ltTipo")
        MiCombo.selectedIndex = 2
        .Document.all("ltTipo") = "Cédula"
        Application.Wait (Now + TimeValue("0:00:01"))
        .Document.all("ltNombres").Value = Celda.Value
         Application.Wait (Now + TimeValue("0:00:01"))
        .Document.all("enviar").Click
        Application.Wait (Now + TimeValue("00:00:01"))
        .Document.getElementsByClassName("cont")(0).Click
          Application.Wait (Now + TimeValue("00:00:02"))
' despues de esto se muestra mi ventana emergente intente hacerlo con sendkeys pero tampo funciona.
End With

Application.Wait (Now + TimeValue("00:00:03"))
SendKeys "^p"
Application.Wait (Now + TimeValue("00:00:03"))
SendKeys "{ENTER}"
Application.Wait (Now + TimeValue("00:00:01"))
SendKeys Celda.Value
Application.Wait (Now + TimeValue("00:00:01"))
SendKeys "~"
Application.Wait (Now + TimeValue("00:00:08"))
Next Celda

IE.Quit

MsgBox "Proceso finalizado"
End Sub



Viewing all articles
Browse latest Browse all 88150

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>