Results 1 to 5 of 5

Thread: Replace Webbrowser for opening Office documents

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2013
    Posts
    73

    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 ?

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Replace Webbrowser for opening Office documents

    Quote Originally Posted by sten2005 View Post
    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)

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Aug 2013
    Posts
    73

    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.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2013
    Posts
    73

    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
  •  



Click Here to Expand Forum to Full Width