Professional Documents
Culture Documents
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www2.bmf.com.br/pages/portal/bmfbovespa/boletim1/TxRef1.asp", _
Destination:=Range("$A$1"))
.Name = "TxRef1"
.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 = """tb_principal1"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
#2) Run another VBA routine to get the data from Excel to SQL Server.
Sub Rectangle1_Click()
'TRUSTED CONNECTION
On Error GoTo errH
With Sheets("Sheet1")
server = .TextBox1.Text
table = .TextBox4.Text
database = .TextBox5.Text
End If
'this is the TRUSTED connection string
Set rs.ActiveConnection = con
intImportRow = intImportRow + 1
Loop
con.Close
Set con = Nothing
End With
Exit Sub
errH:
MsgBox Err.Description
End Sub