Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2012, 05:36 PM
ubns ubns is offline Macro to replace one specific heading style with another Windows 7 32bit Macro to replace one specific heading style with another Office 2010 32bit
Competent Performer
Macro to replace one specific heading style with another
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default Another issue

Hi Paul,



Sorry to ask this again, I am just trying to make it work.

Now it is giving the error "Style not found". I thought something should be wrong with the style name, however when I clicked on the Debug, the error was on some other line. See the attached image and code is below
Code:
Sub Document_Open()
Dim StrSty As String, i As Long
StrSty = "Custom Breakout,Custom Breakout Subheading,Custom Page Heading," & _
  "Custom Page Subheading 1.0,Table Grid, Umesh Table"
With ActiveDocument
  With .Content.find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = True
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Text = "monitor"
    .Replacement.Text = "review"
    .Execute Replace:=wdReplaceAll
    .Text = "folder or on a seperate disc"
    .Replacement.Text = "folder"
    .Execute Replace:=wdReplaceAll
  End With
  If InStr(.Sections.First.Footers(wdHeaderFooterFirstPage).Range.Text, "Statement of Advice") > 0 Then
    For i = 0 To UBound(Split(StrSty, ","))
      Application.OrganizerCopy Source:=.AttachedTemplate.FullName, Destination:=.FullName, _
        Name:=Split(StrSty, ",")(i), Object:=wdOrganizerObjectStyles
    Next
  End If
End With
End Sub
Attached Images
File Type: png Macro Issue.PNG (38.0 KB, 12 views)
Reply With Quote
  #2  
Old 08-23-2012, 05:41 PM
macropod's Avatar
macropod macropod is offline Macro to replace one specific heading style with another Windows 7 64bit Macro to replace one specific heading style with another Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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 ubns View Post
Hi Paul,

Sorry to ask this again, I am just trying to make it work.

Now it is giving the error "Style not found". I thought something should be wrong with the style name, however when I clicked on the Debug, the error was on some other line.
In all likelihood, it's because the template the code looks at isn't your's anymore, but the user's.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to replace one specific heading style with another Create and save custom heading style ubns Word 3 08-01-2012 09:42 PM
Macro to replace one specific heading style with another Modify a numbered heading style TheQueenBea Word 3 06-05-2012 12:12 PM
Macro to replace one specific heading style with another Changing numbering in a Heading style TheQueenBea Word 1 05-31-2012 02:22 PM
Macro to replace one specific heading style with another Very frequent heading style, but still not built in Word!!!!! why??? Jamal NUMAN Word 17 06-30-2011 05:47 PM
How to have this Heading – Table of contents style? Jamal NUMAN Word 0 01-13-2011 06:02 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:17 PM.


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