Avatar of mauricerichard
mauricerichard
 asked on

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

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

Open in new window

.NET Programming

Avatar of undefined
Last Comment
Minh Võ Công

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Minh Võ Công

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.
fblack61