XL97: How to Create Web Query (.iqy) Files
This article was previously published under Q157482
This article has been archived. It is offered "as is" and will no longer be updated.
This article explains how to create Web query (.iqy) files for use withMicrosoft Excel 97.
In Microsoft Excel 97, Web queries allow you to query data from a specificWorld Wide Web, Internet, or intranet site and retrieve the informationdirectly into a Microsoft Excel worksheet. Microsoft Excel 97 includes somesample Web queries.
Definition of a Web Query FileA Web query file is a text file that contains from one to four lines oftext where each line of text is separated by a carriage return. Web queryfiles can be created in any text editor, such as Notepad, and they aresaved with the .iqy extension.
Creating a Web Query FileTo create a Web query file, follow these steps:
- Start a text editor, such as Notepad.
- Type the four lines of text in the text editor using the following information:First Line: Type of QueryThe first line in the Web query file tells Microsoft Excel what type of query the file contains. At this time, the following are the only valid query types:
WEB <line omitted>
If you omit the line, WEB is the assumed value.Second Line: Version of QueryThe second line of a Web query file tells Microsoft Excel the version of the query that is being executed. At this time, the following are the only valid versions:
1 <line omitted>
NOTE: If you specify the type of query in the first line, you must specify a version in the second line. If you omit the type, you must also omit the version.Third Line: Uniform Resource Locator (URL)The third line of a Web query file determines the Web document on which the query acts. Unless the Web document is a POST type (see the "Fourth Line: POST Parameters" section), this information is the only required value in the Web query file .
Type the URL in one of the following formats.
File location URL format ------------------------------------------------------------------- Web document http://<server>/<file> File stored locally <drive>:\<directory>\<file> File stored on a network \\<server>\<share>\<directory>\<file>where <server> is the server name that contains the Web document or file on the network drive, <file> is the name of the document, <drive> is the drive that contains the local file, <directory> is the folder name that contains the local file, and <share> is the name of the share on the server.Fourth Line: POST ParametersThe fourth line of a Web query file contains POST parameters. Note that this line is optional and must be included only if the third line (the URL) exceeds 200 characters in length as a result of adding parameters.
When you query a Web document for information, the parameters sent to the Web document can be sent in one of two ways: GET or POST.
When you use the GET method, data values are included in the same line as the URL. The following example illustrates how to type the line
http://<server>/<file>parameters>where <server> is the name of the server that contains the Web document, and <file> is the name of the document.
When you use the POST method, data values are sent in a separate line. The following example illustrates how to type the line
http://<server>/<file> parameterswhere <server> is the name of the server that contains the Web document, and <file> is the name of the document.
- After you type all the required lines, save the new file as a text file with the .iqy extension (for example, save the file as Myquery.iqy).
- Quit the text editor.
Using Static and Dynamic Parameters in a Web QueryIn Web queries, you can use static and/or dynamic parameters. Staticparameters send query data without prompting you for any values. Dynamicparameters prompt you to type one or more values when the Web query isexecuted.
The syntax for parameters is as follows:
<parameter>=<value string>where <parameter> is the name of a parameter (for example, stock) and<value string> is a value.
The value string can be one of the following values.
Parameter type Value string ----------------------------------------------------------- Static value1 Dynamic ["value1","Please enter the first value:"]In the dynamic value string, the first argument (value1) is the name of thevalue to be entered. The second argument is the message that appears whenthe Web query is executed.
If multiple parameters are required, separate them with an ampersandcharacter (&). The following example illustrates the syntax:
quote1=stock1"e2=stock2When multiple values are sent for a single parameter, separate them with aplus sign (+). The following example illustrates the syntax:
quote1=stock1+stock2"e2=stock3+stock4You can combine static and dynamic parameters within a single parameterstring. The following example illustrates the syntax:
quote1=stock1"e2=["stock2","Please enter the second value:"]
Examples of Web Query FilesThe following examples are designed to demonstrate the syntax used by Webquery files in Microsoft Excel 97.
NOTE: The following examples are not functional Web queries.
This example sends the value "wyut" to the Client.exe and retrieves avalue. You are not prompted to type any values. The parameter is sent usingthe GET method.
WEB 1 http://www.weylandyutani.com/cgi-bin/client.exe?quote=wyutIf you like, you can omit the first two lines and use the following line:
http://www.weylandyutani.com/cgi-bin/client.exe?quote=wyutIt is acceptable to omit the first two lines when you create the .iqy file.This is true for all of the examples shown in this article.
This example sends the values "wyut" and "hypd" to the Client2.exe, andthen retrieves values. You are not prompted to type any values. Theparameters are sent using the POST method.
WEB 1 http://www.weylandyutani.com/cgi-bin/client2.exe quote1=wyut"e2=hypdExample Three:
This example prompts you to type a stock symbol, sends that symbol to theClient.exe, and retrieves a value. The parameters are sent using the GETmethod.
NOTE: The third and fourth lines of this example should be typed on asingle line in your text file.
WEB 1 http://www.weylandyutani.com/cgi-bin/client.exe?quote1= ["stock1","Please enter a stock symbol:"]
Example FourThis example sends the value "wyut" and a value that you are prompted toenter to the Client2.exe, and then retrieves the values. The parameters aresent using the POST method.
WEB 1 http://www.weylandyutani.com/cgi-bin/client2.exe quote1=wyut"e2=["stock2","Please enter a stock symbol:"]
"Microsoft Excel Web Resource Kit for Microsoft Excel 97," pages 4-6
Article ID: 157482 - Last Review: 12/04/2015 15:31:38 - Revision: 2.0
Microsoft Excel 97 Standard Edition
- kbnosurvey kbarchive kbfaq kbofficeupdate kbprb kbweb KB157482