Open MS Word Application inside an IE frame

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.


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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>

okeanos1012Author Commented:
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.
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.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

okeanos1012Author Commented:
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
okeanos1012Author Commented:
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.
okeanos1012Author Commented:
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
okeanos1012Author Commented:
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
okeanos1012Author Commented:
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."
okeanos1012Author Commented:
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?      
okeanos1012Author Commented:
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.

okeanos1012Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.