Link to home
Start Free TrialLog in
Avatar of gregoryew
gregoryew

asked on

What is the best way to display a Word document inside a visual basic application

I have a question that hopefully one of the experts on this message board can please answer for me.  I want to be able to store a Word document in a SQL Server database and retrieve it and display inside a Visual Basic 6 application with as minimal user steps and as cleanly as possible.  What is the best way to do this?  I have tried using the OLE control and it did not do what I want because it did not clip the document to the size of the OLE control for some reason when in view mode.  I tried to use the Web Browser control but it asked the user if he wanted to download the file and I dont know how to turn that off.  I tried using OLE Automation but I want the document to be inside the Visual Basic 6 application.  Is that possible?  I just want the user to be able to see the document, not edit it, and not be able to save the document or open another document using Word.  Any help on choosing the best method would be greatly appreciated.
Thanks,
Greg
Avatar of edwardiii
edwardiii

Hi, gregoryew.

I tested setting Webbrowser1.navigate("myWordDoc.doc") with both files located on my desktop and files stored on our intranet document server.  In either case the only pop-up I got was when a Word document contained macros/vba.  Otherwise the Word docs displayed in the WebBrowser didn't allow users to open other instance of Word (e.g. the Word menu isn't displayed), and yes they could make edits, but when the WebBrowser control is closed no edits are saved.

For the popup you mention, possible entering WebBrowser1.Silent = True will do the job.  If you absolutely don't want users to be able to click anywhere in the Word doc (or type in it, etc.), I can give you some API code that would put a block over the entire WebBrowser control's surface area.  Let me know:)
Is it possible to convert your documents to RTF, then use a locked RichTextBox to view the documents?
Avatar of gregoryew

ASKER

Thanks for the responses but I am still having problems.  I tried to save the test document as rtf to make sure all macros were removed and open the file in the Web Browser control but I still got a similar error message which is "Some files can harm your computer.  If the file information below looks suspicious, or you do not fully trust the source, do not open or save this file."  I saved the file as a text document and opened it in the web browser control without a problem.  I even tried creating the document in word pad and still got the same problem.  I would rather not save the document as rich text because I want to store the document in the database and use words digital signature functionality which I dont think is available as a rich text format.  Also the code which edwardiii mentioned would be a good idea because I tried editting the document in the webbrowser control and it asked me if I wanted to save the document and the users could be confused by that.
Thanks,
Greg
Did you try opening the RTF document in the Rich Textbox control instead?
Thanks for the help but as I previously stated I dont want to save the document in the RTF format because I would lose the digital signature functionality.  Also I would prefer not to save the document in two different formats like RTF and Word or HTML and Word but that maybe what I have to do.
Thanks,
Greg
ASKER CERTIFIED SOLUTION
Avatar of edwardiii
edwardiii

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial