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
ASKER CERTIFIED SOLUTION
Avatar of Minh Võ Công
Minh Võ Công
Flag of Viet Nam image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo