Saltar al contenido

¿Cómo poner el nombre deseado al archivo?


Recommended Posts

Tengo un código VBA que abre una web y hace búsquedas y abre la ventana de guardar la web como PDF no tengo idea como hacer que el nombre del archivo a guardar sea el mismo que el usado para búsqueda (uso los datos de la columna A).

 

Cita

Option Explicit
Sub ExtraerDatos()
Dim IE 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
Application.ScreenUpdating = False
Set IE = CreateObject("InternetExplorer.Application")
Let UltimaFila = Cells(Rows.Count, 1).End(xlUp).Row
IE.navigate "http://192.168.1.76/frmPrincipal.aspx"
IE.Visible = True
For Each Celda In Range("A2:A" & UltimaFila)
Application.Wait (Now + TimeValue("0:00:03"))
With IE
.Document.getElementById("txtDato").Value = Celda.Value
.Document.getElementById("btnCon").Click
.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
End With
Next Celda
IE.Quit
Set IE = Nothing
Application.ScreenUpdating = True
MsgBox "Proceso finalizado"
End Sub

 

 

Enlace a comentario
Compartir con otras webs

Hola, te dejo la respuesta que te di en otro foro. Obvio es la idea, ajústalo a tu necesidad:

Option Explicit

Sub ExtraerDatos()
Dim IE 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

Application.ScreenUpdating = False

Set IE = CreateObject("InternetExplorer.Application")
Let UltimaFila = Cells(Rows.Count, 1).End(xlUp).Row

IE.navigate "http://192.168.1.76/frmPrincipal.aspx"
IE.Visible = True

For Each Celda In Range("A2:A" & UltimaFila)

Application.Wait (Now + TimeValue("0:00:03"))

With IE
    .Document.getElementById("txtDato").Value = Celda.Value
    .Document.getElementById("btnCon").Click
    .ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
End With

Application.Wait (Now + TimeValue("0:00:05"))
SendKeys Celda.Value, True
SendKeys "{TAB}"
SendKeys "~"

Application.Wait (Now + TimeValue("0:00:05"))

Next Celda

IE.Quit

Set IE = Nothing
Application.ScreenUpdating = True
MsgBox "Proceso finalizado"

End Sub

Saludos

Abraham Valencia

 

Enlace a comentario
Compartir con otras webs

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

×
×
  • Crear nuevo...

Información importante

Echa un vistazo a nuestra política de cookies para ayudarte a tener una mejor experiencia de navegación. Puedes ajustar aquí la configuración. Pulsa el botón Aceptar, si estás de acuerdo.