Microsoft KB Archive/178222

From BetaArchive Wiki
Knowledge Base


Article ID: 178222

Article Last Modified on 3/27/2007



APPLIES TO

  • Microsoft Internet Explorer 4.0 128-Bit Edition
  • Microsoft Internet Explorer 5.0
  • Microsoft Office 97 Developer Edition



This article was previously published under Q178222

SUMMARY

The purpose of this document is to explain how to control the client-side behavior when a hyper-text link to a Word document is selected. For example, clicking on a link to a Word document usually defaults to opening the document from within Internet Explorer. You can change this behavior so that the link opens the file in Word.

This article applies to both a desktop user of Internet Explorer, as well as a Web author, writing client-side script. Although this article is tailored to MS Word, the concepts apply to other Microsoft document applications (that is, Excel).

MORE INFORMATION

The following two basic approaches to controlling the behavior will be discussed:

  • As a user, you can set client options through Windows Explorer. The advantage of this approach is that the user retains control of the browser's behavior.
  • As a Web author, you can write client-side script. The advantage of this approach is that you can customize the client behavior from a central location. However, there is a caveat: implementing this method requires a client-based installation of Office 97 and is inherently slow.

Use the following steps for the first approach--setting client options through Windows Explorer:

  1. Launch Windows Explorer.
  2. If you are running Microsoft Windows NT 4.0, follow these steps:
    1. On the View menu, click Options. If Internet Explorer 4.0 is installed, click Folder Options.
    2. In the Options dialog box, click the File Types tab.
    3. In Registered file types, click Microsoft Word Document, and then click Edit.

    If you are running Microsoft Windows 2000 or a later version of Windows, follow these steps:

    1. On the Tools menu, click Folder Options.
    2. In the File Options dialog box, click the File Types tab.
    3. In Registered file types, click Microsoft Word Document, and then click Advanced.
  3. From the Edit File Type screen, click to clear the Browse in same window check box, which toggles whether a Word document is launched outside of Internet Explorer.
  4. Click OK to close the dialog boxes.

Note that behind the scenes, simple Registry flags are being set, which means that someone with experience in creating .Reg files can automate this change.

For the second approach, as a Web author you can control the behavior of a Word document through OLE Automation, provided the client is running Microsoft Word. Here are the basic steps:

  1. Create a client-side function that instantiates Microsoft Word, and accepts the URL of the document as its argument.
  2. Create a button to call the function, passing the URL of the Word document.

    Here's a sample client-side script using automation with Word 97 installed on the client computer:

       <HTML>
       <HEAD>
       <SCRIPT LANGUAGE=VBScript>
       Dim objWord
       Sub Btn1_onclick()
       call OpenDoc("http://MyServer/MyTest.doc")
       End Sub
    
       Sub OpenDoc(strLocation)
    
       Set objWord = CreateObject("Word.Application")
       objWord.Visible = true
       objWord.Documents.Open strLocation
       End Sub
    
       </SCRIPT>
       <TITLE>Launch Word</Title>
       </HEAD>
       <BODY>
       <INPUT TYPE=BUTTON NAME=Btn1 VALUE="Open Word Doc">
       </BODY>
       </HTML>
                        


NOTE For Word Automation to succeed, you must set your browser to Enable or to Prompt for Initialize and script ActiveX controls not marked as safe . If you set your browser to Disable, then the earlier sample code may produce a runtime error and may not work as expected.

REFERENCES

For more information about Word automation, click the following article numbers to view the articles in the Microsoft Knowledge Base:

195826 CreateObject fails from client-side scripts


198703 How to automating Excel from client-side VBScript


286023 How to use a VB ActiveX component for Word automation from Internet Explorer


239470 Cannot call GetObject from script in IE to access running object


For additional information, visit the following Microsoft Developer Network Web site:

Web development


Additional query words: hyperlink

Keywords: kbhowto KB178222