Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
#27074
Bom dia a todos,

meu caso é o seguinte, tenho um código que uma parte eu gravei e outra eu peguei na internet, esse código faz login e baixa uma tabela específica em um determinado site, o que ocorre é que, quando eu fecho a planilha o código para de funcionar, e só volta a fazer a mesma coisa quando substituo a parte que gravei por uma outra gravação de macro. Alguém poderia me ajudar a achar esse erro e fazer com que a macro funcionasse outra vez sem ter que gravar outra?


desde já agradeço a todos.



Dim HTMLdoc As HTMLDocument
Dim oBrowser As InternetExplorer
Dim oHTML_Element As IHTMLElement
Dim sURL As String
Dim CommandButton1_Click() As Adjustments

Sub Login()
Call Application.OnTime(Now + TimeValue("00:20:00"), "Login") 'timer


On Error GoTo Err_Clear
sURL = "http://xxxxxxxxxxxxxx/"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.Navigate sURL
oBrowser.Visible = True

Do
Loop Until oBrowser.ReadyState = READYSTATE_COMPLETE

Set HTMLdoc = oBrowser.document
HTMLdoc.all.user.Value = "xxxxxxx"
HTMLdoc.all.pw.Value = "xxxxxxx"

For Each oHTML_Element In HTMLdoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For

Next
Err_Clear:

Resume Next

' parte da gravação da macro
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://xxxxxxxxxxxxxxxxxxx", Destination:=Range("$A$3") _
)
.CommandType = 0
.Name = "bugs"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery = True
End With


End Sub
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord