|
-
Aug 21st, 2013, 06:51 AM
#1
Thread Starter
Lively Member
Replace Webbrowser for opening Office documents
In have a VB6 application which can display office documents (mainly Word and Excel) using a Webbrowser control as explained in:
http://support.microsoft.com/kb/243058
But with Office 2007 and later this doesn't work as well because it opens a new window for the document rather than using the Webbrowser control. You can get around this by modifying the registry, but this isn't always possible.
Can anyone point me to an alternative method to display documents?
I need to be able to open .doc, .docx, .xls, .xlsx and possibly others. I don't need to edit the documents, just view them. I only need one document opened at a time.
I have seen suggestions of using PreviewHandlers hosting or of embedding the application in a form.
What is the best approach, and is there any code available ?
-
Aug 21st, 2013, 11:03 AM
#2
Re: Replace Webbrowser for opening Office documents
 Originally Posted by sten2005
But with Office 2007 and later this doesn't work as well because it opens a new window for the document rather than using the Webbrowser control.
. . .
Can anyone point me to an alternative method to display documents?
. . .
What is the best approach, and is there any code available ?
Perhaps the code demonstrated here may help.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Aug 21st, 2013, 11:19 AM
#3
Re: Replace Webbrowser for opening Office documents
The best practice is to avoid doing this at all at any cost.
Microsoft once offered an unsupported library containing the "DSOFramer control" that was meant to handle just this thing. Several years ago they not only pulled the library download, but expunged the MS KB article and ran to hide in a corner.
The problem is that the Office Team at Microsoft does not play well with others. They routinely break Windows application rules and create nasty messes for anything that has to interact with Office programs.
See MS KB311765 and DsoFramer are missing from MS site and much other world wide wailing and gnashing of teeth.
-
Aug 29th, 2013, 10:59 AM
#4
Thread Starter
Lively Member
Re: Replace Webbrowser for opening Office documents
Hi Dilettante,
Thanks for your reply. I'm aware of the DsoFramer control, but I've never liked to use it for the reasons you allude to.
I've never had any problems using the WebBrowser control as a document viewer (Microsoft recommend it in KB 243058). Though with Office 2007 and later trying to view a document causes it to open in Word/Excel instead (still OK but doesn't look as good). You can fix this (http://support.microsoft.com/kb/927009) for Office 2007 by modifying the registry but you may not have permissions to do this.
-
Aug 29th, 2013, 11:15 AM
#5
Thread Starter
Lively Member
Re: Replace Webbrowser for opening Office documents
Hi Bonnie,
Thanks for your reply.
I tried jmsrickland's code but (if I'm understanding correctly) it didn't make any difference
Basically what I am doing is:
Code:
WebBrowser1.Navigate "C:\Test\Test.doc"
as recommended in http://support.microsoft.com/kb/243058 to open a Word document.
It works fine until Office 2007, which (by design) opens the document in Word instead.
So now I am trying to find a way of either opening a 2007/2010 document in the webbrowser control or finding a different method of viewing the document.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|