Link to home
Start Free TrialLog in
Avatar of Musiqal
Musiqal

asked on

Show/Hide table in footer Word 2010

Does anyone know why i can't show/hide table in footer of first page with this line:

ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range.Tables(1).Range.Font.Hidden = True

But with the same line shortned i'm still able to use and it remove the table:

 ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range.Tables(1).Delete
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Do you have the Option to show hidden text (as included in the 'Show all formatting marks' setting)?
Avatar of Musiqal
Musiqal

ASKER

Yes
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Musiqal

ASKER

Is it possible to do the same thing without using the hide technique, a solution that is even cleaner?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Musiqal

ASKER

Okey cool, but how would i do the same thing using a building block as you suggested?
Avatar of Musiqal

ASKER

Thanks for the help, if you have some good links on building blocks that would be great as well, cheers! :)
This is a very comprehensive article on Building blocks. There are a couple of VBA snippets toward the end, one of which shows how to insert Building block text on to a document.

http://gregmaxey.mvps.org/word_tip_pages/building_blocks_autotext.html
Avatar of Musiqal

ASKER

Fantastic, thank u! :)
Avatar of Musiqal

ASKER

How do i delete the shape after adding it according to your instructions, the line below only makes it flicker?

 ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Shapes(1).Delete
Avatar of Musiqal

ASKER

Sorry made a typical newb mistake, now i've got it to work, but i'm getting this error number 70 where it says access denied, when running these two following lines:


ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Shapes.SelectAll
Selection.Delete
Why nor stick to the method that you say worked in your penultimate comment?

ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Shapes(1).Delete
Avatar of Musiqal

ASKER

Used it and it works fine, but now these lines from your suggestion throw this error, what i've done is that i've entered in a hardcoded value, but it would have been nice to know the width of the table dynamically as your solution proposes


Throwed error:

Run time error 5992
Cannot access individual columns in this collection because the table has
mixed cell widths.

Code:

 For Each col In tbl.Columns
        sngWidth = sngWidth + col.Width
 Next col
Avatar of Musiqal

ASKER

Solved it by accessing the width through the cells instead, thanks anyway! :)