Automate Excel URL Web Query

Z

Zedox

Synopsis:
I made this winforms application that automates a webpage from data the user
inputs. The webpage collects data and puts it into a database (it's a tab
delimited format). All I have to do is make a URL web query so that the
information is automatically inserted into the Excel file when the user opens
the excel file and click refresh.

What I want:
For the user to open the Excel File and press "Refresh" to get the
information from the webpage.

Question:
How do I set an Excel Object's URL Web Query?

What I know how to do:
Create an Excel Object, Workbook, and Worksheet.

Language of Choice:
C#

Thank you in advance. If I am not clear in what I want to do, please tell me
so I can elaborate.
 
S

SCrowley

Zedox,

I don't speak C# but I am learning Excel and VBA.

I hope something in this code answers your question:

MSExcel 2007

Sub WebQuery()
'
' WebQuery Macro
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.google.com/ig?hl=en", Destination:=Range("$F$1"))
.Name = "ig?hl=en"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top