Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-14-2011, 06:39 PM
cksm4 cksm4 is offline Save Selection Windows XP Save Selection Office 2007
Advanced Beginner
Save Selection
 
Join Date: Aug 2010
Posts: 48
cksm4 is on a distinguished road
Default

Hey Paul,

Quote:
What are you trying to loop - the Sections or adding to the 'IndexThis' bookmark


Each document will always have the wording "Category 1" near the top of the document. Since I will be combining the documents into one document prior to running the below code, I decided not to use a bookmark to place the index. I just have the code go the next row after the last category is found and paste the index there. This next row is blank and can be used for this.

Code:
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Category 1"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
vCatagory1 = Selection.Text
Selection.Collapse
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Category 2:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
vCatagory2 = Selection.Text
Selection.Collapse
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Category 3"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCell
vCatagory3 = Selection.Text
Selection.MoveRight Unit:=wdCell
ActiveDocument.Indexes.MarkEntryRange:=Selection.Range, _
Entry:=vCatagory1 & ":" & vCatagory2 & ":" & vCatagory3, CrossReference:="", CrossReferenceAutoText:="", _
BookmarkName:="", Bold:=False, Italic:=False


I would be nice to also limit the code to sections so that if somehow it found "Category 1" and not "Category 2" it does not go to the next section (another form) looking for "Category 2". Just me being cautious!

Quote:
From what you've described so far, Find/Replace is not a good way to approach this IMHO.




I can use code to find ContentControl(1) because I will be combining multiple of these forms into one document prior to running this code. It is my understanding then that after I do this, the code will only find one ContentControl(1)... the one on the last form. The ones on all the rest of the forms will rename.

Thanks again Paul!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox updating from combobox selection paxile2k Word VBA 0 10-26-2010 02:30 PM
Document selection procedure kennethc Word 0 09-15-2010 02:56 PM
The modification is not allowed because selection is locked aligahk06 Word 0 09-06-2010 06:28 AM
Automatic find replace after selection in dropdown vsempoux Word 0 10-28-2009 08:45 AM
Highlighted Selection on Action Settings mos7sad PowerPoint 0 10-12-2009 07:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:09 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft