How do I add a table header to a Word document header using VB.net?

I need to add the header of my Word table to the header of page 2 and above in a Word document.  I have it appearing on the first page but none there after.  I think I know where the problem is but I don't know how to fix it.  Any help is most welcomed!!

Here is the code.  I think the bolded area is where I need to put something but what?  

With oDoc
                oSec = .Sections(1)
                oSec.PageSetup.DifferentFirstPageHeaderFooter = True
                oSec.Range.InsertAfter("Appendix E: White Sands Test Facility Reporting Period:  " & trainee & vbCrLf & "Summary of Maximum Concentrations, Current Concentrations and T-C Plot Interpretations for WSTF Monitoring Well Network")

               oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, 1, 19)
               oTable.Range.ParagraphFormat.SpaceBefore = 3
                oTable.Range.ParagraphFormat.SpaceAfter = 3
                oTable.Borders.Enable = True
                oTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
                oTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
                oTable.Range.Font.Bold = False
                oTable.Range.Font.Size = 8
                oTable.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
                oTable.Range.Font.Color = Word.WdColor.wdColorBlack
                oTable.Range.Font.Italic = False
               
                'column headings
                oTable.Cell(1, 1).Range.Text = CStr("Well")
                oTable.Cell(1, 2).Range.Text = CStr("First" & vbCrLf & "Sample")
                oTable.Cell(1, 3).Range.Text = CStr("Interpretation")

                oTable.Cell(1, 4).Range.Text = CStr("F11" & vbCrLf & "Max")
                oTable.Cell(1, 5).Range.Text = CStr("F11" & vbCrLf & "Year")
                oTable.Cell(1, 6).Range.Text = CStr("F11" & vbCrLf & "Last")
                oTable.Cell(1, 7).Range.Text = CStr("F11" & vbCrLf & "Year")

                oTable.Cell(1, 8).Range.Text = CStr("F113" & vbCrLf & "Max")
                oTable.Cell(1, 9).Range.Text = CStr("F113" & vbCrLf & "Year")
                oTable.Cell(1, 10).Range.Text = CStr("F113" & vbCrLf & "Last")
                oTable.Cell(1, 11).Range.Text = CStr("F113" & vbCrLf & "Year")

                oTable.Cell(1, 12).Range.Text = CStr("TCE" & vbCrLf & "Max")
                oTable.Cell(1, 13).Range.Text = CStr("TCE" & vbCrLf & "Year")
                oTable.Cell(1, 14).Range.Text = CStr("TCE" & vbCrLf & "Last")
                oTable.Cell(1, 15).Range.Text = CStr("TCE" & vbCrLf & "Year")

                oTable.Cell(1, 16).Range.Text = CStr("NDMA" & vbCrLf & "(607)" & vbCrLf & "Max")
                oTable.Cell(1, 17).Range.Text = CStr("NDMA" & vbCrLf & "(607)" & vbCrLf & "Year")
                oTable.Cell(1, 18).Range.Text = CStr("NDMA" & vbCrLf & "(607)" & vbCrLf & "Last")
                oTable.Cell(1, 19).Range.Text = CStr("NDMA" & vbCrLf & "(607)" & vbCrLf & "Year")

                oTable.Rows(1).Shading.BackgroundPatternColor = Word.WdColor.wdColorGray15
                oTable.Columns.Item(1).Width = oWord.InchesToPoints(0.7) ' well
                oTable.Columns.Item(2).Width = oWord.InchesToPoints(0.75)
                oTable.Columns.Item(3).Width = oWord.InchesToPoints(0.8)

                oTable.Columns.Item(4).Width = oWord.InchesToPoints(0.6) '
                oTable.Columns.Item(5).Width = oWord.InchesToPoints(0.4)
                oTable.Columns.Item(6).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(7).Width = oWord.InchesToPoints(0.4)
                oTable.Columns.Item(8).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(9).Width = oWord.InchesToPoints(0.4)
                oTable.Columns.Item(10).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(11).Width = oWord.InchesToPoints(0.4)
                oTable.Columns.Item(12).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(13).Width = oWord.InchesToPoints(0.4)
                oTable.Columns.Item(14).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(15).Width = oWord.InchesToPoints(0.4)
                oTable.Columns.Item(16).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(17).Width = oWord.InchesToPoints(0.5)
                oTable.Columns.Item(18).Width = oWord.InchesToPoints(0.6)
                oTable.Columns.Item(19).Width = oWord.InchesToPoints(0.5)

                oSec.Headers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Text = "Appendix E:  Summary of Maximum Concentrations, Current Concentrations and T-C Plot Interpretations for WSTF Monitoring Well Network" _
                   & vbCrLf ' ===== DO I PUT SOMETHING HERE??? ====

                '=====================================================

                oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Text = "NASA White Sands Test Facility for Reporting Period:  " & trainee
            End With
Karen WilsonProgrammerAsked:
Who is Participating?
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.

GrahamSkanRetiredCommented:
I might be wrong, but I think that you are confusing the table heading with the document header.

You can set the table heading like this:
MyTable.Rows(1).HeadingFormat = true

Open in new window

You could use the document header instead, but it won't look like part of the table. And anyway, in this case you specify that the first page header is different, so it won't be repeated on the  following pages.
0

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
Karen WilsonProgrammerAuthor Commented:
I am going to try your method as it makes more sense.  I was trying to duplicate how the report was given to me, which had the table header also as the document header.  Thanks!
0
Karen WilsonProgrammerAuthor Commented:
Perfect!! Thanks so much!!

For those who want to know what I did, see below:

oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, hCount + 1, 19)
                    oTable.Range.ParagraphFormat.SpaceBefore = 3
                    oTable.Range.ParagraphFormat.SpaceAfter = 3
                    oTable.Borders.Enable = True
                    oTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
                    oTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle
                    oTable.Range.Font.Bold = False
                    oTable.Range.Font.Size = 8
                    oTable.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphLeft
                    oTable.Range.Font.Color = Word.WdColor.wdColorBlack
                    oTable.Range.Font.Italic = False
                    oTable.Rows(1).HeadingFormat = True
0
GrahamSkanRetiredCommented:
Pleased to have got you on the right track. Thank you for the feedback.
0
Ritesh HegdeCommented:
Hello,

I would like to add two footers in a word document using VB.net script. How is this possible? Can any1 help me.?

Basically I need something which has a left side footer and right side footer. I think, we need to add 2 column table as footer but i am not sure how to do this.

Thanks in advance for help.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.