[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control


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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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 …
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Suggested Courses

656 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