Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2011, 01:52 PM
macropod's Avatar
macropod macropod is offline Save Selection Windows 7 32bit Save Selection Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


Quote:
Originally Posted by cksm4 View Post
I am assuming that the name of the control (1, 2, 3... etc) is based on its order. Is this true? Is it possible to name a control differently?
I believe so.
Also, once I have merged all my documents together, is there a way to run this by section?[/quote]Simple. Try something along the lines of:
Code:
Sub Demo()
Dim strTmp As String, iSctn As Integer
iSctn = InputBox("Which Section to process?")
If iSctn = "" Then Exit Sub
With ActiveDocument.Sections(iSctn).Range
  strTmp = .ContentControls(1).Range.Text
  strTmp = strTmp & ":" & .ContentControls(2).Range.Text
  strTmp = strTmp & ":" & .ContentControls(3).Range.Text
  .Indexes.MarkEntry Range:=.Bookmarks("IndexThis").Range, _
    Entry:=strTmp, CrossReference:="", CrossReferenceAutoText:="", _
    BookmarkName:="", Bold:=False, Italic:=False
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 01-13-2011, 02:33 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,

The bookmark will no longer work because as documents are combined, it just keeps getting replaced. I used the below code to go to the next row to input the index.

Code:
 
Dim strTmp As String, iSctn As Integer
iSctn = InputBox("Which Section to process?")
If iSctn = "" Then Exit Sub
With ActiveDocument.Sections(iSctn).Range
  strTmp = .ContentControls(2).Range.Text
  strTmp = strTmp & ":" & .ContentControls(4).Range.Text
  strTmp = strTmp & ":" & .ContentControls(3).Range.Text
  Selection.MoveRight Unit:=wdCell
  ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, _
    Entry:=strTmp, CrossReference:="", CrossReferenceAutoText:="", _
    BookmarkName:="", Bold:=False, Italic:=False
End With
Would it also be possible to have the code run the whole document automatically as opposed to allowing the user to select sections?
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 11:05 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