troubleshooting Question

ASP.NET - reading the header section of a word document

Avatar of mauricerichard
mauricerichard asked on
.NET Programming
1 Comment1 Solution405 ViewsLast Modified:
Hello Experts,

I have an application that allows the user to browse for a word document, and retrieves the contents.  This part is working fine.  The problem is, I don't know how to retrieve the header info.

See the code I'm using below to retrieve the rest of the document contents.

Many Thanks,
Moe

    Public Shared Function Return_Word_Document_Contents(ByVal strUploadPath_and_FileName As String) As String
        'Setup word class, file path, and null object to open word document 
        Dim wordApp As New ApplicationClass()
        Dim nullobj As Object = System.Reflection.Missing.Value

        'Instantiate the document - requires 9 arguments even if they're null
        Dim doc As Document = wordApp.Documents.Open(strUploadPath_and_FileName, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj, nullobj)

        'Make content live & store it in a string
        Dim strDocumentContent As String = doc.Content.Text

        'Close the document
        doc.Close(nullobj, nullobj, nullobj)

        'Return the value
        Return strDocumentContent
    End Function
ASKER CERTIFIED SOLUTION
Minh Võ Công

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros