Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-08-2018, 07:06 PM
bobk544 bobk544 is offline Need to apply Heading1 to select rows Windows 7 32bit Need to apply Heading1 to select rows Office 2010 32bit
Novice
Need to apply Heading1 to select rows
 
Join Date: Apr 2009
Posts: 10
bobk544 is on a distinguished road
Default Need to apply Heading1 to select rows

Hello, i need to apply the Heading1 style to every every row that has the text string of


"C:\_XREF_ALL\App.2018" and the result i'm hoping for is that i will be able to collapse and expand the rows under each Heading1. And basically, this document contains a lot of program code and the beginning of each program starts with the C drive directory reference ie C:\_XREF_ALL\App.2018\Program1 for example. So i'm hoping that when i apply the Heading1 to the full row, i will be able to expand and collapse each program section of code, thanks for any help on this!

Code:
Sub HeaderApply()
Application.ScreenUpdating = False
Dim StrFnd As String, StrSty As String, StrRep As String, i As Long
StrFnd = "C:\_XREF_ALL\App.2018"
StrSty = " Strong,Heading 1,Character Style 1,Italic,Character Style 2"
StrRep = "Placeholder1^& Placeholder2,^&,^&,Placeholder3^& Placeholder4,^&"
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Format = True
  .Wrap = wdFindContinue
  .MatchWildcards = True
  .Text = ActiveDocument.Range  'trying to get the whole row text here
  .Replacement.Style = StrSty
  .Execute Replace:=wdReplaceAll
  'For i = 0 To UBound(Split(StrFnd, ","))
  '  .Text = "#" & Split(StrFnd, ",")(i) & "[A-Za-z]@>"
  '  .Replacement.Style = Split(StrSty, ",")(i)
  '  .Replacement.Text = Split(StrRep, ",")(i)
  '  .Execute Replace:=wdReplaceAll
  'Next
End With
Application.ScreenUpdating = True
End Sub

Last edited by macropod; 06-08-2018 at 07:28 PM. Reason: Added code tags
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to apply Heading1 to select rows Select rows w/cells containing given character strings, then sum cell in two other col. LarryHills Excel 1 02-17-2017 03:55 PM
VBA Word Table - Select More than 1 Column at a time - Apply Formatting jc491 Word VBA 12 09-24-2015 06:03 AM
Need to apply Heading1 to select rows TOC showing both Heading1 and Page Number FormatAdmin Word 3 03-04-2014 01:20 PM
Need to apply Heading1 to select rows reference previous heading1 fehenry Word 5 04-20-2012 01:54 AM
Heading1 does not convert to Kop1 boesh Word 8 07-02-2010 05:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:46 PM.


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