Solved

Open MS Word Application inside an IE frame

Posted on 2003-10-24
15
59,497 Views
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.

Thanks!

0
Comment
Question by:okeanos1012
[X]
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
15 Comments
 
LVL 4

Expert Comment

by:JNSTAUB
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>
   <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>

0
 

Author Comment

by:okeanos1012
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.
0
 
LVL 4

Expert Comment

by:JNSTAUB
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.
0
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
LVL 4

Expert Comment

by:JNSTAUB
ID: 9627999
0
 

Author Comment

by:okeanos1012
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.

0
 
LVL 4

Accepted Solution

by:
JNSTAUB earned 200 total points
ID: 9632220
0
 

Author Comment

by:okeanos1012
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.
0
 

Author Comment

by:okeanos1012
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
http://www.microsoft.com/mind/0898/dom.asp
0
 

Author Comment

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

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/overview/overview.asp

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
    UserControl.Parent.parentWindow.Parent
    UserControl.Parent.parentWindow.navigotor
0
 

Author Comment

by:okeanos1012
ID: 9657700
Opps, hit the Submit button prematurely.  I've also tried to get to the Webbrowser level using:
   UserControl.Parent.parentWindow.eternal
   UserControl.Parent.parentWindow.window

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."
0
 

Author Comment

by:okeanos1012
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

3)
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?      
0
 

Author Comment

by:okeanos1012
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.

0
 

Author Comment

by:okeanos1012
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
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
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 set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

724 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