• WSAndrew77

    WSAndrew77

    @wsandrew77

    Viewing 8 replies - 571 through 578 (of 578 total)
    Author
    Replies
    • in reply to: Macro to Delete CharChar styles (Word 2002) #826096

      The original code I posted choked when I tried it on a *real* char style (one that’s actually a linked style, as opposed to the behavior I described above in Word 2000). I got a Runtime Error 4198: Command failed on the line:

       sty.Delete 

      But I noticed that, in fact, the style was deleted. Adding an On Error Resume Next line made it work like a charm.

      It’s hard to create test files for this, so if anyone’s got a really messy “char char” document, I’d love to test this on it. I’m going to (very) tentatively say this works for Word 2000+. I’d love feedback, of course.

      Sub MyDeleteCharCharStyles()
      Dim sty As Style
      Dim i As Integer
      Dim doc As Document
      Dim sStyleName As String
      Dim bCharCharFound As Boolean
      Set doc = ActiveDocument
      Do
          bCharCharFound = False
          For i = doc.Styles.Count To 1 Step -1
              Set sty = doc.Styles(i)
              sStyleName = sty.NameLocal
              If sStyleName Like "* Char*" Then
                  bCharCharFound = True
                  If sty.Type = wdStyleTypeCharacter Then
                      On Error Resume Next
                      sty.Delete
                  Else
                      sty.NameLocal = Replace(sStyleName, " Char", "")
                  End If
              Exit For
              End If
              Set sty = Nothing
          Next i
      Loop While bCharCharFound = True
      End Sub

      P.S. / FYI — Another way to remove aliases from a style is with the split function:

      Set sty = ActiveDocument.Styles("Style Name,with,many,aliases")
      sty.NameLocal = Split(sty.NameLocal, ",")(0)
      
    • in reply to: Macro to Delete CharChar styles (Word 2002) #826097

      The original code I posted choked when I tried it on a *real* char style (one that’s actually a linked style, as opposed to the behavior I described above in Word 2000). I got a Runtime Error 4198: Command failed on the line:

       sty.Delete 

      But I noticed that, in fact, the style was deleted. Adding an On Error Resume Next line made it work like a charm.

      It’s hard to create test files for this, so if anyone’s got a really messy “char char” document, I’d love to test this on it. I’m going to (very) tentatively say this works for Word 2000+. I’d love feedback, of course.

      Sub MyDeleteCharCharStyles()
      Dim sty As Style
      Dim i As Integer
      Dim doc As Document
      Dim sStyleName As String
      Dim bCharCharFound As Boolean
      Set doc = ActiveDocument
      Do
          bCharCharFound = False
          For i = doc.Styles.Count To 1 Step -1
              Set sty = doc.Styles(i)
              sStyleName = sty.NameLocal
              If sStyleName Like "* Char*" Then
                  bCharCharFound = True
                  If sty.Type = wdStyleTypeCharacter Then
                      On Error Resume Next
                      sty.Delete
                  Else
                      sty.NameLocal = Replace(sStyleName, " Char", "")
                  End If
              Exit For
              End If
              Set sty = Nothing
          Next i
      Loop While bCharCharFound = True
      End Sub

      P.S. / FYI — Another way to remove aliases from a style is with the split function:

      Set sty = ActiveDocument.Styles("Style Name,with,many,aliases")
      sty.NameLocal = Split(sty.NameLocal, ",")(0)
      
    • in reply to: Macro to Delete CharChar styles (Word 2002) #826086

      Hi Phil,

      I’ve attached a file that contains four styles (well, besides the defaults). “Quote,q” and its accompanying “char” style, and “>ListBullet,>lb” and its accompanying “char” style.

      I don’t know off hand which version of word these styles came from.

      Since Word 2000 doesn’t support the LinkStyle property, I’m guessing it just splits them into two styles, one paragraph and one character. Sometimes, though, there’s no character style created, just a paragraph style showing up with “char char” in the name.

      The macro I posted earlier represents the general algorithm I use to cleanse them from Word 2000: delete the character ones, and rename the paragraph ones.

      I’m at home on Word 2003 now, so can’t get a better sample for you.

    • in reply to: Macro to Delete CharChar styles (Word 2002) #826087

      Hi Phil,

      I’ve attached a file that contains four styles (well, besides the defaults). “Quote,q” and its accompanying “char” style, and “>ListBullet,>lb” and its accompanying “char” style.

      I don’t know off hand which version of word these styles came from.

      Since Word 2000 doesn’t support the LinkStyle property, I’m guessing it just splits them into two styles, one paragraph and one character. Sometimes, though, there’s no character style created, just a paragraph style showing up with “char char” in the name.

      The macro I posted earlier represents the general algorithm I use to cleanse them from Word 2000: delete the character ones, and rename the paragraph ones.

      I’m at home on Word 2003 now, so can’t get a better sample for you.

    • in reply to: Macro to Delete CharChar styles (Word 2002) #825958

      Hi Gary (et al),

      Since the LinkStyle property isn’t available in Word 2000, Gary’s macro won’t work for that version. I had long been just fixing the “char char” styles manually, but Gary’s macro prompted me to take a stab at automating it. (Actually, Gary’s macro prompted me to try and just use his macro — it was discovering to my dismay that it didn’t work on Word 2000 that actually got me doing my own coding wink .)

      This macro retains any existing aliases, and it also allows for styles whose names start with “Char”.

      I’ve tested this on a bunch of documents with “Char Char” styles, and it seemed to work pretty well. But I’d love any feedback or suggestions (or questions or complaints). I haven’t tested it on Word 2003, but will do so tonight.

      Sub Word2000DeleteCharCharStyles()
      Dim sty As Style
      Dim i As Integer
      Dim doc As Document
      Dim sStyleName As String
      Dim bCharCharFound As Boolean
      Set doc = ActiveDocument
          
      Do
          bCharCharFound = False
          For i = doc.Styles.Count To 1 Step -1
              Set sty = doc.Styles(i)
              sStyleName = sty.NameLocal
              If sStyleName Like "* Char*" Then
                  bCharCharFound = True
                  If sty.Type = wdStyleTypeCharacter Then
                      sty.Delete
                  Else
                      sty.NameLocal = Replace(sStyleName, " Char", "")
                  End If
                  Exit For
              End If
              
              Set sty = Nothing
          Next i
      Loop While bCharCharFound = True
      End Sub

      The Do…While Loop is there because renaming a style dynamically changes its location in the Styles collection. This was a quick way to accommodate that. Again, comments are welcome.

    • in reply to: Macro to Delete CharChar styles (Word 2002) #825959

      Hi Gary (et al),

      Since the LinkStyle property isn’t available in Word 2000, Gary’s macro won’t work for that version. I had long been just fixing the “char char” styles manually, but Gary’s macro prompted me to take a stab at automating it. (Actually, Gary’s macro prompted me to try and just use his macro — it was discovering to my dismay that it didn’t work on Word 2000 that actually got me doing my own coding wink .)

      This macro retains any existing aliases, and it also allows for styles whose names start with “Char”.

      I’ve tested this on a bunch of documents with “Char Char” styles, and it seemed to work pretty well. But I’d love any feedback or suggestions (or questions or complaints). I haven’t tested it on Word 2003, but will do so tonight.

      Sub Word2000DeleteCharCharStyles()
      Dim sty As Style
      Dim i As Integer
      Dim doc As Document
      Dim sStyleName As String
      Dim bCharCharFound As Boolean
      Set doc = ActiveDocument
          
      Do
          bCharCharFound = False
          For i = doc.Styles.Count To 1 Step -1
              Set sty = doc.Styles(i)
              sStyleName = sty.NameLocal
              If sStyleName Like "* Char*" Then
                  bCharCharFound = True
                  If sty.Type = wdStyleTypeCharacter Then
                      sty.Delete
                  Else
                      sty.NameLocal = Replace(sStyleName, " Char", "")
                  End If
                  Exit For
              End If
              
              Set sty = Nothing
          Next i
      Loop While bCharCharFound = True
      End Sub

      The Do…While Loop is there because renaming a style dynamically changes its location in the Styles collection. This was a quick way to accommodate that. Again, comments are welcome.

    • in reply to: Final Showing Markup… can’t get it to change (2003) #820092

      Check the setting marked “Make Hidden Markup Visible When Opening or Saving” under Tools->Options->Security. Even though all the changes may have been accepted, if there’s a Comment or other Markup it may be triggering the “Final showing markup” view.

      HTH!

    • in reply to: Final Showing Markup… can’t get it to change (2003) #820093

      Check the setting marked “Make Hidden Markup Visible When Opening or Saving” under Tools->Options->Security. Even though all the changes may have been accepted, if there’s a Comment or other Markup it may be triggering the “Final showing markup” view.

      HTH!

    Viewing 8 replies - 571 through 578 (of 578 total)