How to create a table with multiple rows and columns in header?

E

Eric

How to create a table with multiple rows and columns in
header?
Thank you very much.
 
E

Eric

But what wrong in my codes? Please help me. I am just a
beginner in vba.

Dim tb1 As Table
Dim rng As Word.Range
Set rng = ActiveDocument.Sections(1).Headers
(wdHeaderFooterFirstPage).Range

Set tb1 = ActiveDocument.Sections(1).Headers
(wdHeaderFooterFirstPage).Range.Tables.Add
(Selection.Range, 5, 5)
 
J

Jezebel

The Tables.Add instruction is a little unexpected in that you have to
specify the range to which the table belongs both as the object to which you
apply the method, and as an argument to the function. Currently you're using
Selection.Range as an argument, which is not what you want. Try

Dim tb1 As Word.Table
Dim rng As Word.Range
Set rng = ActiveDocument.Sections(1).Headers (wdHeaderFooterFirstPage).Range
Set tb1 = rng.Tables.Add(rng, 5, 5)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top