Hola necesito realizar una macro en excel que me conecte a una web y me extraiga datos

como dice el titulo eso es lo que necesito lo hice grabando la macros y funciono perfecto pero al momento de cerrar el libro de excel no me ejecuta . Por que la pagina donde extraigo los datos tengo que loguearme y después dirigirme a otra pagina donde sacar los dato . Intente poner los datos de usuario para loguearme pero no me funciono este es mi código

Sub camilo()
'
' camilo Macro
'
'
Const Nick = "usuario"
Const Pass = "contraseña"
For Each Q In ActiveSheet.QueryTables
Q.Delete
Next Q
ActiveSheet.Cells.Clear
'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://172.29.64.101", _
Destination:=Range("$A$1"))
.PostText = "usuario=" & Nick & "&password=" & Pass
.Refresh BackgroundQuery:=False
.Connection = "URL;http://172.29.64.101/panel/panel_12.php?choice=energ%C3%ADa&rfsh=Manual"
.Name = "panel_12.php?choice=energía&rfsh=Manual"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "17"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("D:D,E:E,F:F,G:G,H:H").Select
Range("H1").Activate
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.AutoFilter
ActiveSheet.Range("$C$1:$C$167").AutoFilter Field:=1, Criteria1:=Array( _
"CHB01", "CHR02", "COB02", "COB03", "TEB01", "TEB02"), Operator:=xlFilterValues
Range("B81").Select
Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
ActiveWindow.SmallScroll Down:=-3
End Sub

Añade tu respuesta

Haz clic para o