Office Add-in please help

Techsavy
Techsavy used Ask the Experts™
on
Hi,

I am trying to create an MS-WORD add-in which will read the value from a table in the header of the word document and use that as the filename to save to sharePoint document library.

Can anyone help me create this word-in? the file name should be the value from the second row of the table in the header.

Please help,

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I don't use Sharepoint so cannot comment on that part, but to get the value from the table in the header should be simple enough. The following will read the value of the first cell in the second row of the first table in the header to a string strFname, which you can use to name the document


Dim oHeader As HeaderFooter
Dim oTable As Table
Dim oCell As Range
Dim strFname As String

For Each oHeader In ActiveDocument.Sections(1).Headers
    If oHeader.Exists Then
        If oHeader.Range.Tables.Count > 0 Then
            Set oTable = oHeader.Range.Tables(1)
            Set oCell = oTable.Cell(2, 1).Range
            oCell.End = oCell.End - 1
            strFname = "my path\" & oCell.Text & ".docx"
            Exit For
        End If
    End If
Next oHeader
MsgBox strFname

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial