MANIPULAR VENTANAS EMERGENTES

Miltoner77

New Member
Joined
Dec 18, 2019
Messages
3
Office Version
2016
Platform
Windows, Web
Hola, agradezco su ayuda, tengo un código creado, que funciona correctamente, el código abre la web, y un formulario, el inconveniente es que debo dar clic en un enlace para ver el resultado, hasta que todo esté bien, el resultado se muestra en una ventana emergente, y necesito guardar esta ventana con archivo pdf, cosa que no conseguimos.

[CÓDIGO = vba] Opción explícita

Sub ExtraerDatos ()
Dim Ie como objeto
Dim MiCombo como objeto
Dim c As Long, UltimaFila As Long
Dim Celda As Range

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

Establecer Ie = CreateObject ("InternetExplorer.Application")
Deje UltimaFila = Celdas (Rows.Count, 1) .End (xlUp) .Row
Es decir, visible = verdadero
Es decir, Navigate2 "RedInServ"

Hacer mientras Ie.readyState <> READYSTATE_COMPLETE
DoEvents
Lazo
Para cada Celda In Range ("A2: A" y UltimaFila)

Con Ie
Establecer MiCombo = Ie.document.all ("ltTipo")
MiCombo.selectedIndex = 2
.document.all ("ltTipo") = "Cédula"
Application.Wait (ahora + TimeValue ("0:00:01"))
.document.all ("ltNombres"). Value = Celda.Value
Application.Wait (ahora + TimeValue ("0:00:01"))
.document.all ("enviar"). Haga clic en
Application.Wait (ahora + TimeValue ("00:00:01"))
.document.getElementsByClassName ("cont") (0) .Haga clic
Application.Wait (ahora + TimeValue ("00:00:02"))
'despues de esto se muestra mi ventana emergente intente hacerlo con sendkeys pero tampo funciona.
Terminar con

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

Es decir, traje

MsgBox "Proceso finalizado"
End Sub [/ CODE]
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,216
Office Version
2007
Platform
Windows
Hi, welcome to the board! (Hola, bienvenido al foro!)

Apparently your window translator also translated the VBA code, you could paste the code again, but check that it does not translate automatically.
That way someone can help you.

(Al parecer tu traductor de ventana también tradujo el código de VBA, podrías pegar nuevamente el código, pero revisa que no se traduzca en automático.
De esa forma alguien podrá ayudarte.
)
 

Miltoner77

New Member
Joined
Dec 18, 2019
Messages
3
Office Version
2016
Platform
Windows, Web
VBA Code:
Option Explicit

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
 

Watch MrExcel Video

Forum statistics

Threads
1,102,764
Messages
5,488,703
Members
407,654
Latest member
IDAL

This Week's Hot Topics

  • Timer in VBA - Stop, Start, Pause and Reset
    [CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
  • how to updates multiple rows in muliselect listbox
    Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
  • Delete Row from Table
    I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
  • Assigning to a variable
    I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
  • Way to verify information
    Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
  • Active Cell Address – Inactive Sheet
    How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...
Top