Time-Outs in XMLHTTP, and Controls with a View

Got a problem or a stumper question on anything to do with Internet or Windows-based development? Ask the good doctor ([email protected]); he's here for you each and every week, right on MSDN Online Voices. Though his busy surgery schedule precludes answering every question, he'll answer as many as he can-and if yours is picked, he'll be glad to send you a t-shirt!


Dear Dr. GUI,
I am using the following simple code to retrieve and send XML over HTTP:

SAMPLE ONE: (below)

The way it is written, the process waits until the Send command is over before continuing. I need to control a time-out, so that if I get no answer in 10 seconds, for instance, the process can go on. How can I accomplish this? Should I use the asynchronous mode of the Microsoft.XMLHTTP component?

Thank you very much for your help.
Jose J. Sanjose

Dr. GUI replies:

The good doctor feels your pain. Let's examine your situation to arrive at the proper diagnosis.

First, Jose, there's no need to wait for a command when there are alternatives. From the good doctor's analysis, it appears that you need to closely examine the alternatives and then choose your own method of treatment.

Unfortunately, the XMLHTTP component does not support time-out settings. Also, the asynchronous processing in this component is only designed for scripting environments. For example, the ReadyState and OnReadyStateChange properties of XMLHTTP are not readily accessible from Microsoft Visual Basic or Microsoft Visual C++.

But let the good doctor make a suggestion that should help ease your pain and get you back to work quickly: You could use an alternate component that is designed for server-side usage, ServerXMLHTTP. For more information on this component, see the Microsoft Knowledge Base article Q290761: Frequently Asked Questions about ServerXMLHTTP.

When using the ServerXMLHTTP component, you can use the SetTimeouts method to achieve the required time-out settings. To see the method documentation, go to setTimeouts Method.

A side note: your code is using the older ProgID, Microsoft.XMLHTTP. You can see the new ProgIDs for this object at IXMLHTTPRequest. You can also find the new ProgIDs for other components in the SDK.

By the way, the good doctor notices that you are using an older way of coding access to COM objects. Consider using the #import syntax and smart pointers; it's considerably easier. You can learn more about these at Dr. GUI on Components, COM, and ATL.

So try this, take two aspirin, and come visit Dr. GUI in six months for a checkup.

Using Office Documents on the Web

Dear Dr. GUI,

Using the OLE Viewer Tool, which is shipped with Visual Studio, I found a control called "Microsoft Office Spreadsheet 9.0" under the Control section. This control is for opening an Excel spreadsheet. Are there any controls like this for opening a Word document, a PowerPoint file, or an Access file?

Thank you.
Kannan Sivasankaran

Dr. GUI replies:

Thank you, Kannan, for giving the good doctor an opportunity to "weigh in" on the controls and components for Microsoft Office. The doctor is putting on his professor's hat and invites you and the rest of his readers into the hospital's lecture room to listen to the good doctor expound.

Microsoft Office SpreadSheet 9.0 is an ActiveX control that comes with Microsoft Office Web Components. The Office Web Components are a set of Component Object Model (COM) controls that come with Microsoft Office 2000 or the upcoming Microsoft Office XP release. The other controls that are included in the library are Chart Component, PivotTable Component, and Data Source Component. In short:

-The SpreadSheet Component is similar to a small version of Excel spreadsheet, complete with a spreadsheet user interface and recalculation engine that supports nearly all of the calculation functions in Microsoft Excel

-The Chart Component is similar to Excel charting, supporting most of the two-dimensional chart types in Excel as well as a Polar chart type

-The PivotTable Component is designed to deliver interactive data reporting and analysis, and provides functionality similar to Excel PivotTable

-The Data Source Component is used to get Data from external sources and can be used by other controls as Data source

For samples on Office Web Components, see the Microsoft Knowledge Base article Q258187: OWebComp.exe Contains Scripting Samples for the Office 2000 Web Components.

Yes? Is there a hand up in the last row? What? The good doctor hasn't really answered your question yet? He does get carried away with the sound of his own voice, doesn't he?

Well, the answer to the original question is "no." There are no Office Web Components that allow opening Word Documents, PowerPoint presentations, or Access tables or reports. This is not a problem, however, because there are alternative methods you can use to address each of the situations about which you've inquired.

For Microsoft Word documents: If you do not have Microsoft Word installed on your computer, you can use Word Viewer to read the Word document files. Word 2000 also allows you to save Word documents as HTML pages, so that they can be displayed in a browser.

For Microsoft PowerPoint presentations: If you do not have Microsoft PowerPoint installed on your computer, you can use PowerPoint Viewer to view the presentation. PowerPoint 2000 also allows you to save and publish the presentation as a Web page, so that you can run the entire presentation interactively on the Web.

Note: You can find all of the Viewers for Microsoft Office products at Microsoft Office Converters and Viewers.

For Microsoft Access: Microsoft Access allows you to create data access pages, which can be published on an intranet or the Internet. A data access page is a special type of Web page designed for viewing and working with data (stored in a Microsoft Access Database or a Microsoft SQL Server database) from the Internet or an intranet. With this, you can view and modify data from the database on the Web. You can, as well, save Access tables and reports as static HTML pages, but there is no interactivity in this case. Finally, you can save Access reports in snapshot (.snp) format. These can be opened in either snapshot viewer (SnapView.exe) or snapshot viewer ActiveX control (snapview.ocx). For more information on Access snapshot viewer, see the Microsoft Knowledge Base article Q172348: ACC97: Report Snapshots and Microsoft Snapshot Viewer.

The lecture is over. Good luck with this!


The good doctor has taken off his robes and professor's hat, hung then up neatly in his closet, and is now going to take a well-deserved nap. He can do this because he always has the best and brightest team of dedicated folks assisting him. This week: Karthi Karthikeyan and Ranjit R. Sawant, with a special thanks to Penny Riker for setting up the chairs in the lecture room.

The following article originally appeared in the MSDN Online Voices
Ask Dr. GUI Weekly colum

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.