R
Roderick O'Regan
I'm working in Word 2002 and Windows XP Pro SP2
I have a template which has on each page, bar the first, a coloured
logo within a table in each footer.
The following code iterates through each footer looking for the inline
picture in cell 3 of row 1 and replaces it with a monochrome version
saved as AutoText:
'Iterate through all story types in the current document
For Each kStory In ActiveDocument.StoryRanges
'Iterate through all linked stories
Do
On Error Resume Next
Select Case kStory.StoryType
Case wdPrimaryFooterStory, wdEvenPagesFooterStory,
wdFirstPageFooterStory
'first deletes the coloured logo in the footers
If kStory.Tables.Count > 0 Then
kStory.Tables(1).Cell(1, 3).Range.Delete
'inserts the B&W logo in the footers
Set myRange = kStory.Tables(1).Cell(1, 3).Range
myRange.Collapse Direction:=wdCollapseStart
ActiveDocument.AttachedTemplate.AutoTextEntries(" Mono logo").Insert
_
Where:=myRange, RichText:=True
Exit Sub
End If
Case Else
'Do Nothing
End Select
On Error GoTo 0
'Get next linked story (if any)
Set kStory = kStory.NextStoryRange
Loop Until kStory Is Nothing
Next
'go back to the top of the document
Set myRange = Nothing
Set kStory = Nothing
ActiveDocument.Bookmarks("\StartofDoc").Select
All of this works perfectly provided it is in portrait orientation.
However, if I now insert a landscape page in the middle of the
document somewhere and remove the "Link to Previous" on the footers
from that point forward the logo only changes up to to the landscape
page and then ignores the rest.
I can see that it might have something to do with my stories
especially as they are now unlinked.
Could anyone suggest, please, a way of going to every footer of each
section irrespective of the footer linked status and then being able
to change that logo?
Roderick
I have a template which has on each page, bar the first, a coloured
logo within a table in each footer.
The following code iterates through each footer looking for the inline
picture in cell 3 of row 1 and replaces it with a monochrome version
saved as AutoText:
'Iterate through all story types in the current document
For Each kStory In ActiveDocument.StoryRanges
'Iterate through all linked stories
Do
On Error Resume Next
Select Case kStory.StoryType
Case wdPrimaryFooterStory, wdEvenPagesFooterStory,
wdFirstPageFooterStory
'first deletes the coloured logo in the footers
If kStory.Tables.Count > 0 Then
kStory.Tables(1).Cell(1, 3).Range.Delete
'inserts the B&W logo in the footers
Set myRange = kStory.Tables(1).Cell(1, 3).Range
myRange.Collapse Direction:=wdCollapseStart
ActiveDocument.AttachedTemplate.AutoTextEntries(" Mono logo").Insert
_
Where:=myRange, RichText:=True
Exit Sub
End If
Case Else
'Do Nothing
End Select
On Error GoTo 0
'Get next linked story (if any)
Set kStory = kStory.NextStoryRange
Loop Until kStory Is Nothing
Next
'go back to the top of the document
Set myRange = Nothing
Set kStory = Nothing
ActiveDocument.Bookmarks("\StartofDoc").Select
All of this works perfectly provided it is in portrait orientation.
However, if I now insert a landscape page in the middle of the
document somewhere and remove the "Link to Previous" on the footers
from that point forward the logo only changes up to to the landscape
page and then ignores the rest.
I can see that it might have something to do with my stories
especially as they are now unlinked.
Could anyone suggest, please, a way of going to every footer of each
section irrespective of the footer linked status and then being able
to change that logo?
Roderick