Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA
Selection.Find.Execute FindText:=OrigDocID, ReplaceWith:=NewVersio
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Wes, post: 5871985"] I'm looking for a specific value which is stored in the variable OrigDocID. Pattern matching may pick up other values. This code is used with a document management system, to update the document footer with a new number when it assigned. Here is that section of code: 'OrigDocID and NewVersion are strings SecCt = ActiveWindow.ActivePane.Document.Sections.Count For s = 1 To SecCt 'Loop through the sections 1.1 Selection.GoTo what:=wdGoToSection, which:=wdGoToAbsolute, Count:=s 'Move focus to next section For h = 1 To 3 'three header types Select Case h '1.1.1 Case 1 ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader 'This should insure positioning at top line of footer ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter Case 2 ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryHeader ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter Case 3 ActiveWindow.ActivePane.View.SeekView = wdSeekEvenPagesHeader ActiveWindow.ActivePane.View.SeekView = wdSeekEvenPagesFooter End Select 'End 1.1.1 If Err.Number = 5895 Then 'Check if footer type exists '1.1.2 Err.Clear Else '1.1.2 With Selection '1.1.2.1 Do .HomeKey .MoveRight unit:=wdSentence, Extend:=wdExtend .Find.Execute FindText:=OrigDocID, ReplaceWith:=NewVersion .MoveDown Loop Until Selection.HeaderFooter.IsHeader = True End With 'End 1.1.2.1 End If Next h Next s 'Loop through the sections 1.1 ActiveDocument.Save [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Word Newsgroups
Word VBA
Selection.Find.Execute FindText:=OrigDocID, ReplaceWith:=NewVersio
Top