View Single Post
  #53  
Old 14th December 2012, 04:51 PM
Martinw Martinw is offline
Member
 
Join Date: May 2012
Posts: 40
Default

Hi


Sub queryhtml(wks As Worksheet)
Dim WA As String
WA = wks.Range("AF1").Value



Formhtml = ExecuteWebRequest(WA) ' runs the first function.

outputtext (Formhtml) 'gets the contents held in the file created by the second function

Set Temp_qt = wks.QueryTables.Add(Connection:=WA, Destination:=wks.Range("BA1")) ' creates the link from the tx doc to the sheet.

With Temp_qt
.Name = False
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With

' wks.QueryTables.Item(1).Delete

' Set Temp_qt = Nothing
Kill ThisWorkbook.Path & "\temp.txt" 'deletes the temp txt file.
' If ThisWorkbook.Connections.Count > 0 _
' Then ThisWorkbook.Connections.Item(ThisWorkbook.Connect ions.Count).Delete 'deletes any left over connections.

End Sub
Reply With Quote