Is it possible to programmatically display the contents of a MS Word file in a web page using VB in Visual Studios?

I would like to be able to write an article in MS Word and then programmatically display that article, including links and other formatting  in a web page? Is this possible and what control/container would I use. I use VB in Visual Studios 2012.
Thanks
OhioWoodWrightAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Jacques Bourgeois (James Burger)PresidentCommented:
You would not be able to do so with the Word document saved as a .doc or .docx document, but word has an option to SaveAs .html, which generates a web page. You can then display that web page just as you would any standard web page.
Prakash SamariyaIT ProfessionalCommented:
Need to include below References
Imports Microsoft.Office
Imports Microsoft.Office.Interop.Word
Imports System.IO

Open in new window

CODE TO READ WORD FILE AND SHOW IN TEXTBOX/TEXTAREA/PANEL
'Initiating Application Class
Dim filename As Object = Server.MapPath("FileName")
Dim AC As New Microsoft.Office.Interop.Word.ApplicationClass()
Dim doc As New Microsoft.Office.Interop.Word.Document()
Dim [readOnly] As Object = False
Dim isVisible As Object = True
Dim missing As Object = System.Reflection.Missing.Value
'Reading the word document and put content into textbox
Try
  doc = AC.Documents.Open(filename, missing, [readOnly], missing, missing, missing, missing, missing, missing, missing, missing, isVisible)
  TextBox1.Text = doc.Content.Text
  AC.Documents.Close()
'Error Handling
Catch ex As Exception
End Try

Open in new window

Rafiq J.Net DeveloperCommented:
' Load DOCX or DOC document.
Dim document = DocumentModel.Load(If(isDocx, "Document.docx", "Document.doc"))

' Iterate over all paragraphs in the document.
For Each para As Paragraph In document.GetChildElements(True, ElementType.Paragraph)
    ' Iterate over all runs in the paragraph and write their text to Console.
    For Each run As Run In para.GetChildElements(True, ElementType.Run)
Console.Write(run.Text)
    Next
    Console.WriteLine()
Next
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

OhioWoodWrightAuthor Commented:
Prakesh,

Thanks for the help but I do have a problem. When I try to import Microsoft.Office I get the following error message:

"Namespace or type specified in the Imports 'Microsoft.Office' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."

Any suggestions?

Thanks,
Doug
Jacques Bourgeois (James Burger)PresidentCommented:
Before you Imports a namespace, you need to first reference the dll or application that contains the classes that you want to use.

Add a reference (Project menu) to Microsoft Word in the COM tab of the References window.
Jitendra PatilSr.Software EngineerCommented:
As Jacques suggested you need to convert a docx or doc file to Equivalent HTML and then it will be rendered on the page,  you can try using the code given in below link
Display Word document on web page in ASP.Net

hope this helps.

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
Prakash SamariyaIT ProfessionalCommented:
"Namespace or type specified in the Imports 'Microsoft.Office' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases."
Please follow this steps to add references into your project
1. Right click on Reference folder, it will open Reference Manager in dialog box
2. Goto Extensions tabs from left side, it will load all extensions
3. Select your extension like "Microsoft.Office.Interop.Word" , (click on checkbox)
Note: Select reference that matches version to your system
4. Press OK to add reference in project   (see attached snapshot)Add Reference into Project
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
Visual Basic.NET

From novice to tech pro — start learning today.