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(w dHeaderFoo terFirstPa ge).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(w dHeaderFoo terFirstPa ge).Range. Tables(1). Delete
ActiveDocument.Sections(1)
But with the same line shortned i'm still able to use and it remove the table:
ActiveDocument.Sections(1)
Do you have the Option to show hidden text (as included in the 'Show all formatting marks' setting)?
ASKER
Yes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is it possible to do the same thing without using the hide technique, a solution that is even cleaner?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okey cool, but how would i do the same thing using a building block as you suggested?
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
http://gregmaxey.mvps.org/word_tip_pages/building_blocks_autotext.html
ASKER
Fantastic, thank u! :)
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(w dHeaderFoo terFirstPa ge).Shapes (1).Delete
ActiveDocument.Sections(1)
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(w dHeaderFoo terFirstPa ge).Shapes .SelectAll
Selection.Delete
ActiveDocument.Sections(1)
Selection.Delete
Why nor stick to the method that you say worked in your penultimate comment?
ActiveDocument.Sections(1) .Footers(w dHeaderFoo terFirstPa ge).Shapes (1).Delete
ActiveDocument.Sections(1)
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
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
ASKER
Solved it by accessing the width through the cells instead, thanks anyway! :)