Delete text in first cell of table in footer

L

Legal Learning

My situation has changed a bit since my last post.
Issue:
I may have several sections in a document that may have a different first
page footer and additonal sections that may not. Every footer however will
have a table consisting of 3 columns and one row. The first column will
always contain Page ? of ? field code, a date and time field and document
path and file field plus some text. The second column will have a page
number. I want to delete everything ONLY in the first cell in every section
in every footer. I think I am complicating the issue with my old code. Here
is my new code which is not even selecting in a footer but rather stays in
the document text.

Here is my simplified code (which certainly does not work!)

Dim oSec As Section
For Each oSec In ActiveDocument.Sections

With oSec.Footers(wdHeaderFooterPrimary)'I want this to be all
footers not just primary
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
End With

Next oSec

I am using Word 2003. Thanks for any help
 
G

Greg Maxey

I think this should do:

Sub DeleteSelectedFields2()
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
Do Until (pRange Is Nothing)
Select Case pRange.StoryType
Case wdFirstPageFooterStory, _
wdPrimaryFooterStory, wdEvenPagesFooterStory
On Error Resume Next
pRange.Tables(1).Cell(1, 1).Range.Delete
On Error GoTo 0
Case Else
'Do nothing
End Select
Set pRange = pRange.NextStoryRange
Loop
Next
End Sub
 
L

Legal Learning

You are more than awesome. It is perfect. I admire you for your skills and
talent.

Thanks so very much.
 
G

Greg Maxey

My pleasure and thanks for the compliments. Actually I am just stumbling
along learning a little bit here and there from the folks that are really
good.
 

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