Visual Basic - Convertir este codigo en una funcion personalizada(function)

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Convertir este codigo en una funcion personalizada(function)

Publicado por BELINDA (3 intervenciones) el 09/05/2017 18:18:29
Buenas amigos ,ojala puedan ayudarme tengo este código de visual basic que lo encontre en internet para buscar dni , pero quisiera convertirlo en una function , por ejmplo function buscardni, poner esta formula en una celda y que me arroje el resultado que es el nombre y direccion de la persona.Este el codigo ..Mil gracias
Sub buscardni(NroDoc As String)
Dim URL As String
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim TDelements As IHTMLElementCollection
Dim TDelement As HTMLTableCell
Dim r As Long
Dim HTMLDoc2 As MSHTML.HTMLDocument
Dim TDelements2 As IHTMLElementCollection
Range("b5:b10").ClearContents
Set IE = New InternetExplorer
With IE
.navigate "http://votoinformado.pe/voto/miembro_mesa.aspx"
.Visible = False
While .Busy Or .readyState <> READYSTATE_COMPLETE: DoEvents: Wend
.Document.getElementById("txtCongrDNI").Value = NroDoc
Application.DisplayAlerts = False
.Document.getElementById("btnCongrDNI").Click
Application.DisplayAlerts = True
End With
Set HTMLdoc = IE.Document
While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend

Set HTMLDoc2 = IE.Document
While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set TDelements = HTMLDoc2.getElementsByTagName("Td")
For Each TDelement In TDelements
If r = 1 Then [b5].Value = TDelement.innerText
If r = 3 Then [b7].Value = TDelement.innerText
r = r + 1
Next
IE.Quit
Application.StatusBar = ""
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder