Ai que está o problema, já tentei até achar no IE a opção para deixar salvar como o opção padrão mais não achei.
Da uma olha no codido:
Código: Selecionar todos
Sub Consolida_SUAS()
Dim ie As New InternetExplorer
Dim elemCollection, obj As Object
Dim CurrentWindow As HTMLWindowProxy
Dim objShellWindows As New SHDocVw.ShellWindows
Dim i_URL, i_URL_2
Dim munic, x, t, q, r, c, cod, contador, feitos, tabelas, table, linhas, linhas_tabela, linhas_feitas As Integer
Const lIntervalo As Long = 1000
ie.Navigate "http://aplicacoes.mds.gov.br/suaswebcons/execute.jsf?b=%2AdpotvmubsQbsdfmbtQbhbtNC&event=%2Afyjcjs"
ie.Visible = True
While Not ie.ReadyState = READYSTATE_COMPLETE
Wend
On Error Resume Next
ie.Document.all.Item("form:uf").Item(1).Selected = True
Set CurrentWindow = ie.Document.parentWindow
Call CurrentWindow.execScript("Richfaces.showModalPanel('processando');;A4J.AJAX.Submit('form',event,{'oncomplete':function(request,event,data){Richfaces.hideModalPanel('processando');carregarTooltip();},'similarityGroupingId':'form:j_id98','parameters':{'form:j_id98':'form:j_id98'} } )(workOrderSearchForm)")
Sleep lIntervalo
For munic = 1 To 22
ie.Document.all.Item("form:municipio").Item(munic).Selected = True
cod = ie.Document.all.Item("form:municipio").Value
Set CurrentWindow = ie.Document.parentWindow
Call CurrentWindow.execScript("Richfaces.showModalPanel('processando');;A4J.AJAX.Submit('form',event,{'oncomplete':function(request,event,data){Richfaces.hideModalPanel('processando');carregarTooltip();},'similarityGroupingId':'form:j_id117','parameters':{'form:j_id117':'form:j_id117'} } )(workOrderSearchForm)")
Range("A" & munic).Value = cod
Sleep lIntervalo
ie.Document.all.Item("form:pesquisar").Click
'ie.Document.all.Item("j_id172:j_id303").Click
Dim btnInput As Object ' MSHTML.HTMLInputElement
Dim ElementCol As Object ' MSHTML.IHTMLElementCollection
Set ElementCol = ie.Document.getElementsByTagName("INPUT")
For Each btnInput In ElementCol
If btnInput.Value Like "Gerar Relatório CSV" Then
btnInput.Click
Exit For
End If
Next btnInput
Next munic
ie.Quit
ActiveWorkbook.Save
End Sub