Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing a URL for Excel Web Query

Tags:

excel

vba

I have an Excel 2010 spreadsheet that gets information from a data connection. On the properties of the connection is the "connection string" which is a URL with several parameters that are passed to the server in the query string. If you click "edit query" you can change the URL and then import new data based on the new URL. I need to do this via VBA.

Let's say the connection string is currently http://myserver.com?name=foo I need to change that to http://myserver.com?name=bar

How can this be done?

like image 400
Jimmy D Avatar asked May 24 '11 18:05

Jimmy D


People also ask

How do I change the query connection in Excel?

Edit a query from a worksheet In Excel, select Data > Queries & Connections, and then select the Queries tab. In the list of queries, locate the query, right click the query, and then select Edit.

What is parameterized web query?

Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are used to help define specific content or actions based on the data being passed.

How do you create a query in Excel web?

From the Menu Bar (not the Ribbon), use the Data menu. Choose Get External Data > Run Web Query. (Older versions of Excel say Run Saved Query). The Choose a Query dialog displays defaulting to the Queries folder.

How do you make Excel pull data from a website with login?

Go to Data>From Web to enter your URL, click OK, then select Basic to enter your login credentials to have a check. For more information, you could refer to the Other Sources :Web section of Import data from external data sources.


1 Answers

With ActiveSheet.QueryTables(1)
    .Connection = "URL;" & NewURL
    .Refresh
End With
like image 162
Tim Williams Avatar answered Sep 30 '22 05:09

Tim Williams