Open MS Word Application inside an IE frame

Posted on 2003-10-24
Medium Priority
Last Modified: 2011-08-18
Hello, is there a way to open a Word application inside of a frame?  I need to be able to at the very least display the Standard and Formatting toolbars.

I'm trying to create a web page that has a side menu listing documents in a Case.
When the users select the document, I would like to be able to open up the Word application and load the selected document inside the adjacent frame.

I have been able to open Word documents from the web, but have ran into the following problems:
1)In one environment, when I place the path to the Word document inside an anchor tag, the Word document opens inside the IE browser, but the toolbars do not display. However, I am able to access its menu bar and then display the toolbars.  I need to be able to do this programatically.  I've tried to place the following function inside the document macro but it did not work.

Sub AutoExec()
      ActiveDocument.CommandBars("Standard").Visible = True
End Sub

2)In another environment (also IE), when you click on the link, it downloads the document, and then opens the entire Word application, but not inside of the IE window.  I don't know what setting in IE causes this behavior.  Is there a way for me to program IE to ensure that it behaves like it did in the other environment?

3)I've tried to create an ActiveX control using VB 6 and embed the object inside a frame.  I am able to activate the Word application and load the document, but again, I don't know how to direct the Word application to open inside of the IE container.

Please help.


Question by:okeanos1012
  • 9
  • 4

Expert Comment

ID: 9626004
from msdn:
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:
Launch Windows Explorer.
From the View menu, select Options("Folder Options" if Internet Explorer 4.0 is installed).
From the Options dialog box, click the File Types tab.
From the listing of "Registered File Types," select "Microsoft Word Document," and click Edit.
From the Edit File Type screen, clear the "Browse in same window" check box, which toggles whether a Word document is launched outside of Internet Explorer.
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:
Create a client-side function that instantiates Microsoft Word, and accepts the URL of the document as its argument.
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>
   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

   <TITLE>Launch Word</Title>


Author Comment

ID: 9627625
Hey, thanks for the response!  You have answered my question on how to open the Word document inside the browser insteading of having it be downloaded.  But the bigger question is how do I get the Word application to open inside of a frame, with the menu and toolbars displaying.  One major thing that I had left out is that the Word documents may be stored inside of an Oracle database as a BLOB.   I don't believe that I can retrieve it using VBScript, which is why I  implemented ActiveX control. (Although I could retrieve the BLOB into a file using plsql, it is the path w/the most resistence right now.  Politics, don't ask.)   I have an ActiveX control embedded in one frame.  When I activate it, I hope to be able to download the blob into a file in the client's local directory (I've got this down)and then open it up inside of a frame, with the menu bar and toolbars available.

Expert Comment

ID: 9627894
the example works perfectly even if t's a frame, if you are able to download the blod into a file, simply rename the file with doc extension:
call opendoc("c://tempdownload/mydoc.doc")

for my point of view i answered to your question. now download difficulty and blod conversion is an other question.
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.


Expert Comment

ID: 9627999

Author Comment

ID: 9629239
Hello again.  The article that you've refered me to is pretty good but I'm already able to download and upload my Word document from/to the database using ActiveX.  I am also able to open up the Word document inside a frame.  The problem is opening the Word document and application in its entirety, menus and toolbars and all, inside of a frame.  

When I use your code, the document opened a Word application in a separate window as well.  Is there a way to instantiate the Word object and set its parent container?  Have you tested the code that you wrote out?  If the same code behaves differently in your environment then maybe it's my browser setting.  Also, when I open a Word doc inside of a frame, I get the Word document, but just that and the ruler.  Somehow the menu bar and the toolbars are hidden.


Accepted Solution

JNSTAUB earned 600 total points
ID: 9632220

Author Comment

ID: 9636376
Hey JNSTAUB, guess what I just discovered?  So instead of using the AutoExec() macro inside of a Word document, I used AutoOpen() instead to set the standard and formatting menu to be a floating menu.  I was hoping that if they were floated on top they would be visible.  When I opened up the document in a frame I can see a shadow of the menu, it seems to be hidden behind the web page, behind the frames of the page.  I'm still not sure what to do about it, but atleast I now know that the Word app.  menu is actually there, but it's just hidden.

Author Comment

ID: 9651012
I have found a way to access the IE window that my ActiveX control is embedded in.  In my VB code, I can make the following reference:

   UserControl.Parent.script.document.location = "H:\test\sample.doc"

 Hopefully, by traversing the IE DOM, I can control the Word application as well.
The following article seems promising:

Accessing the Internet Explorer Document Object Model from
Visual Basic 5.0

Author Comment

ID: 9657672
According to the article on the IE browser architecture:


Iexplore.exe is at the top level
Shdocvw.dll (Webbrowser control)
mshtml.dll  (MSHTML)
html (and embedded components such as ActiveX, Java Applets, etc)

Using "UserControl.Parent.parentWindow" I could access the MSHTML level, but I can't seem to go beyond that.  I've tried referencing

Author Comment

ID: 9657700
Opps, hit the Submit button prematurely.  I've also tried to get to the Webbrowser level using:

The reason why I'm trying to access the Webbrowser level is that the article mentioned above states:
"Shdocvw.dll in turn hosts the Mshtml.dll component, as well as any other Active Document component (such as a Microsoft Office application) that can be loaded in place in the browser when the user navigates to a specific document type. Shdocvw.dll supplies the functionality associated with navigation, in-place linking, favorites and history management, and PICS support."

Author Comment

ID: 9660214
Got it! ..almost

1)Add Microsoft Internet Controls to your project's components
2) The following will provide you with the current shellwindows collection, which is all the open windows.

Dim objShell As ShDocVwCtl.ShellWindows
Set objShell = New ShDocVwCtl.ShellWindows

Dim objIE As WebBrowser

For Each objWin IN objShell

   'Find the existing IE browser window that host my web page
   If UCase(objWin.FullName) = UCase("C:\Program Files\Internet    Explorer\iexplore.exe") _
  & UCase(objWin.LocationName) = UCase("test_actx.htm") Then

      Set objIE = objWin                  

   End If      

Next objWin
'Now you can modify the existing browser
objIE.AddressBar = False
I still need to find the Word toolbar and bring it to the front.  Any ideas?      

Author Comment

ID: 9671632
Final resolution!

From my ActiveX control, I download the Word document, which is stored as a BLOB inside an Oracle table, using ADODB.Stream.  Once the document is downloaded, I issue the following statements to redirect the frame to the Word document:
     Dim objCurrBrowser As HTMLWindow2  'Microsoft HTML Object Library
     Set objCurrBrowser = UserControl.Parent.Script.Document.parentWindow
     objCurrBrowser.Frames(1).Location = "H:\My Documents\sample.doc"

Inside of the sample.doc file, I created the following auto macro:
    Sub AutoOpen()
       ActiveDocument.CommandBars("Standard").Visible = True
       ActiveDocument.CommandBars("Formatting").Visible = True
   End Sub

Yep, it's as simple as that!  It's not a perfect solution, but for now, it's good enough for me.


Author Comment

ID: 9682256
Actually, instead of adding the AutoOpen() macro to your document, you may specify the following from the activeX control code after you have redirected  your frame to your Word document location:

Dim objCurrDoc As Word.Document
Set objCurrDoc As Word.ActiveDocument

objCurrDoc.CommandBars("Standard").Visible = True
objCurrDoc.CommandBars("Formatting").Visibile = True

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question