atw: Re: FW: [austechwriter] Re: Word charchar: it's worse than that, Jim
- From: "Steve Hudson" <cruddy@xxxxxxxxxxxxxxxx>
- To: <austechwriter@xxxxxxxxxxxxx>
- Date: Thu, 25 Sep 2003 21:09:00 +1000
That's the first post alright. I think I posted another approach as well...
I dunno. I hate the friggin thing.
Steve Hudson
Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email: steve@xxxxxxxxxxxxxxx
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 728 pages of dump left and dropping...
-----Original Message-----
From: austechwriter-bounce@xxxxxxxxxxxxx
[mailto:austechwriter-bounce@xxxxxxxxxxxxx]On Behalf Of Warren Lewington
Sent: Thursday, 25 September 2003 9:58 AM
To: austechwriter@xxxxxxxxxxxxx
Subject: atw: FW: [austechwriter] Re: Word charchar: it's worse than
that, Jim
Hows about this then Daryl...
-----Original Message-----
From: austechwriter-bounce@xxxxxxxxxxxxx
[mailto:austechwriter-bounce@xxxxxxxxxxxxx] On Behalf Of Steve Hudson
Sent: Tuesday, June 17, 2003 10:22 PM
To: John McGhie; austechwriter@xxxxxxxxxxxxx
Subject: [austechwriter] Re: Word charchar: it's worse than that, Jim
<Shudders> You mangle code sir! Functions return longs, thus integer is
slower as it has to cross convert on the fly. You left out the start
parm in Instr and it even has good use here both times. I reused my old
style name fixer for the para part - that hasnt changed in many
releases. Hot pink is gone as well, I want to fix the problem, not add
to it :-)
Sub FixBadStyles()
'$Author Steve Hudson 17 June 2003
' Inspired by mangled code from McGhie Information Engineering
Pty
Ltd
'$Short Find and fix the cha cha Char styles
Dim aStyle As Style ' Set up variables to hold the bits we need Dim
Index As Long
With ActiveDocument
For Index = 1 To .Styles.Count 'Loop must be restartable
Set aStyle = .Styles(Index) 'Get the next style victim
Select Case aStyle.Type 'It'll either be a para or a char style
Case wdStyleTypeParagraph
' Styles are sorted in Alpha order: if we rename one, we must go back to
the top
If StripParaStyle(aStyle) Then Index = 0
Case wdStyleTypeCharacter
StripCharStyles aStyle
End Select
Next Index ' Examine another style
End With
End Sub
Private Function StripParaStyle(ParaStyle As Style) As Boolean '$Author
The Word Heretic
'$Short Strips off anything after and including the first comma
Const Comma As String = ","
'I've always wanted to declare this variable & type
Dim Appendage As Long
' Look for a comma in the stylename
Appendage = InStr(2, ParaStyle.NameLocal, Comma)
StripParaStyle = (Appendage > 1) 'Is it there?
With aStyle
If StripParaStyle Then .NameLocal = _
Left$(.NameLocal, Appendage - 1) ' Rename End With
End Function
Private Function StripCharStyles(aStyle As Style) As Boolean '$Author
The Word Heretic
' Inspired by mangled code from McGhie Information Engineering
Pty
Ltd
'$Short Resets the bad char styling and sets the underlying paragraph
style
Const Char As String = "Char"
Dim ParaStyle As String
Dim Appendage As Long
Dim Hunter As Range
ParaStyle = aStyle.NameLocal 'Get the name of the style
Appendage = InStr(2, ParaStyle, Char) 'Search for "char" in the style
name
'excluding styles starting with
Char StripCharStyles = (Appendage > 1)
If StripCharStyles Then 'Let's fix it
'String to the left of 'Char' is name of the matching Paragraph style
ParaStyle = Left(aStyle.NameLocal, Appendage - 2)
Set Hunter = ActiveDocument.Content
With Hunter
'Initialise find
'It's a newly created object, no need to clear it
With .Find
.Format = True 'Look for Formatting
.Style = aStyle 'Look for this Char style
.Wrap = wdFindContinue 'Search the whole document
End With
'Do the find and reset
While .Find.Execute 'We found the style
.Font.Reset 'Wipe this user font formatting
.Paragraphs.Style = ParaStyle 'Set the correct underlying style
'and preserve other user
formatting.
Wend
End With
End If
End Function
Steve Hudson
Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
Email: word_heretic@xxxxxxxxxxxx
Products: http://www.geocities.com/word_heretic/products.html
Spellbooks: 735 pages of dump left and dropping...
-----Original Message-----
From: John McGhie [mailto:john@xxxxxxxxxxxxxxxxxxxxxxxxx]
Sent: Tuesday, 17 June 2003 7:12 PM
To: 'Steve Hudson'; austechwriter@xxxxxxxxxxxxx
Subject: RE: [austechwriter] Word charchar: it's worse than that, Jim
{Chortle} 20 minutes ago, I finished coding a macro to sort this...
The price of making it available to you lot is that you VBA Mavens
have to clean up the code for use in my next book!
Note: This flavour has to run on the Mac, because the customer gets it
back from his reviewers who have mauled it in Wd2002 and tries to cope
on MacWd 2001. Thus I can't use the LinkStyle property, which the Mac Wd
doesn't support, which would otherwise provide a rather simpler way of
doing it.
Cheers
**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx
To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject
field.
To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx
with "unsubscribe" in the Subject field.
To search the austechwriter archives, go to
www.freelist.org/archives/austechwriter
To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************
**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx
To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.
To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with
"unsubscribe" in the Subject field.
To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter
To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************
**************************************************
To post a message to austechwriter, send the message to
austechwriter@xxxxxxxxxxxxxx
To subscribe to austechwriter, send a message to
austechwriter-request@xxxxxxxxxxxxx with "subscribe" in the Subject field.
To unsubscribe, send a message to austechwriter-request@xxxxxxxxxxxxx with
"unsubscribe" in the Subject field.
To search the austechwriter archives, go to
www.freelists.org/archives/austechwriter
To contact the list administrator, send a message to
austechwriter-admins@xxxxxxxxxxxxx
**************************************************
- References:
- atw: FW: [austechwriter] Re: Word charchar: it's worse than that, Jim
- From: Warren Lewington
Other related posts:
- » atw: Re: FW: [austechwriter] Re: Word charchar: it's worse than that, Jim
- atw: FW: [austechwriter] Re: Word charchar: it's worse than that, Jim
- From: Warren Lewington