Cover of Suzanne Palmer's book Finder

AW Amazon Store

AW is an Amazon Affiliate

If this site is helpful to you,
Please consider a voluntary subscription to defray ongoing expenses.


paypal subscribe button

How To Support AW

Editing for authors: because every writer needs a good editor.

 

Welcome to the AbsoluteWrite Water Cooler! Please read The Newbie Guide To Absolute Write

Results 1 to 24 of 24

Thread: Helpful Macro

Hybrid View

  1. #1
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703

    Helpful Macro

    This is pretty similar to the set of macros that Roger posted here (in the sticky thread at the top of the forum - if somebody missed 'em :p). In fact, the word list that my macro uses, comes from Roger's macros. I just don't like opening a separate document and then running a macro from that document on my document. So, I wrote my own Word macro which can be accessed directly from the current document and which highlights adverbs, passive words, overly used words and cliches/misused words. This one isn't as user-friendly as Roger's macro since the configuration goes into the macro code itself but hopefully you can figure it out It runs fairly fast since it completed a 90,000+ word document in about 30 seconds. But here's the code ... if anybody needs any help with it, just yell

    Code:
    Sub FAF_WordHighlighter()
    '
    ' WordHighlighter Macro
    ' Highlight specific types of words in current document
    On Error GoTo Err_HighlightWords
    
    	Dim adverbExList
    	Dim passiveList
    	Dim overusedList
    	Dim clicheList
    	Dim adverbColor As WdColorIndex
    	Dim passiveColor As WdColorIndex
    	Dim overusedColor As WdColorIndex
    	Dim clicheColor As WdColorIndex
    	' *** Modify the following section to configure ***
    	adverbExList = Array("only", "oily", "family", "homily", _
    		"Billy", "Sally", "multiply", "imply", "gangly", _
    		"apply", "bully", "belly", "silly", "jelly", "holy", _
    		"lovely", "holly", "fly", "July", "rely", "reply", _
    		"Lilly", "sully", "gully" _
    		)
    	adverbColor = wdYellow
    	passiveList = Array("is", "isn't", "am", "are", "aren't", "was", _
    		"wasn't", "were", "will", "would", "won't", "has", _
    		"had", "have", "be", "been", "do", "don't", _
    		"did", "didn't", "does", "doesn't", "by", "being" _
    		)
    	passiveColor = wdPink
    	overusedList = Array("seem", "seems", "exist", "exists", "appears", _
    		"make", "makes", "show", "shows", "occur", "occurs", "get", _
    		"got", "went", "put", "some", "many", "most", "that", "very", _
    		"extremely", "totally", "completely", "wholly", "utterly", _
    		"quite", "rather", "slightly", "fairly", "somewhat", _
    		"suddenly", "all of a sudden" _
    		)
    	overusedColor = wdTurquoise
    	clicheList = Array("kind of", "sort of", "the reason for", _
    		"past history", "this is why", "end result", _
    		"it is possible that", "the possibility exists", _
    		"for all intents and purposes", "there is a chance that", _
    		"is able to", "has the opportunity to", "past memories", _
    		"future plans", "sudden crisis", "terrible tragedy", _
    		"as a matter of fact", "quite frankly", "all the time", _
    		"white as a sheet", "as soon as possible", "at the very least", _
    		"down in the dumps", "in the nick of time", "hat in hand", _
    		"keep your mouth shut", "made a run for it" _
    		)
    	clicheColor = wdBrightGreen
    	' *** do not modify code beyond this if you don't know what you're doing ***
    	
    	'variables
    	Dim word
    	Dim rng As Range
    	Dim excluded As Boolean
    	Dim story As WdStoryType
    	Dim oldTrack
    	Dim oldHighlight
    	' Save current settings
    	oldTrack = ActiveDocument.TrackRevisions
    	oldHighlight = Options.DefaultHighlightColorIndex
    	ActiveDocument.TrackRevisions = False
    	' Iterate through each document section
    	For Each rng In ActiveDocument.StoryRanges
    		' Work only with the main body, footnotes and endnotes
    		story = rng.StoryType
    		If story <> wdMainTextStory And story <> wdFootnotesStory And story <> wdEndnotesStory Then
    			GoTo NextRange
    		End If
    		' Do the adverb highlighting
    		rng.Find.ClearFormatting
    		rng.Find.Replacement.ClearFormatting
    		With rng.Find
    			.Text = "<[! ]@(ly)>"
    			.Forward = True
    			.Wrap = wdFindStop
    			.Format = False
    			.MatchCase = False
    			.MatchWholeWord = False
    			.MatchWildcards = True
    			.MatchSoundsLike = False
    			.MatchAllWordForms = False
    		End With
    		Do While rng.Find.Execute(Replace:=wdNone) = True
    			If rng.Text = "" Then
    				Exit Do
    			End If
    			excluded = False
    			For Each word In adverbExList
    				If rng.Text = word Then
    					excluded = True
    					Exit For
    				End If
    			Next
    			If Not excluded Then
    				' Highlight current selection
    				rng.HighlightColorIndex = adverbColor
    			End If
    		Loop
    		' Obtain range again
    		Options.DefaultHighlightColorIndex = passiveColor
    		rng.WholeStory
    '		Set rng = ActiveDocument.StoryRanges.Item(story)
    		' Do passive word highlighting
    		rng.Find.ClearFormatting
    		rng.Find.Replacement.ClearFormatting
    		rng.Find.Forward = True
    		rng.Find.Wrap = wdFindContinue
    		rng.Find.Replacement.Highlight = True
    		rng.Find.Format = True
    		rng.Find.MatchCase = False
    		rng.Find.MatchWholeWord = True
    		rng.Find.MatchWildcards = False
    		rng.Find.MatchSoundsLike = False
    		rng.Find.MatchAllWordForms = False
    		For Each word In passiveList
    			rng.Find.Text = word
    			rng.Find.Execute Replace:=wdReplaceAll
    		Next
    		' Do overused word highlighting
    		Options.DefaultHighlightColorIndex = overusedColor
    		rng.WholeStory
    		For Each word In overusedList
    			rng.Find.Text = word
    			rng.Find.Execute Replace:=wdReplaceAll
    		Next
    		' Do misused word/cliche highlighting
    		Options.DefaultHighlightColorIndex = clicheColor
    		rng.WholeStory
    		For Each word In clicheList
    			rng.Find.Text = word
    			rng.Find.Execute Replace:=wdReplaceAll
    		Next
    NextRange:
    	Next
    	' Restore saved settings
    	ActiveDocument.TrackRevisions = oldTrack
    	Options.DefaultHighlightColorIndex = oldHighlight
    	MsgBox "Word highlighting complete!"
    	Exit Sub
    Err_HighlightWords:
    	MsgBox Err.Description
    End Sub
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  2. #2
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    Oh yeah, if anybody doesn't know what to do with the above code, all you've got to do is open Word, go to Tools - Macro - Macros ... and click on the Create button. This should open up the macro editor. Simply copy the above code, paste it in and click the Save button and then close the Macro Editor. You should be done When you want to run it, you go back to Tools - Macro - Macros ... select the FAF_WordHighlighter macro and click the Run button - it will process the currently open document.
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  3. #3
    Poet. Veteran. Comic Book Maker jst5150's Avatar
    Join Date
    Sep 2005
    Location
    The South
    Posts
    4,739
    Excellent work. Thanks for this.
    “You cannot overestimate the unimportance of practically everything.” -- Maxwell

    I write and draw a printed space opera/scifi comic book, "Vorpal": http://headshrinkerspress.com/vorpal

  4. #4
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    You're welcome
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  5. #5
    Not wanting to appear stupid or anything... but wouldn't it be better to learn to write more competently, rather than relying on macros to make you look better?
    and now hang with the staff at the café for creative people:

  6. #6
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    Mike, the macro's not going to automatically substitute words for you and hence, there really is no "making you look better" involved All it does is highlight what's already there in your document and point out patterns of usage. You can either take the suggestions and learn from them (hence learning to write more competently) or ignore them. Again, each individual's choice
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  7. #7
    Moderator In Name Only AW Moderator Roger J Carlson's Avatar
    Join Date
    Feb 2005
    Location
    West Michigan
    Posts
    12,815
    Quote Originally Posted by Mike Coombes
    Not wanting to appear stupid or anything... but wouldn't it be better to learn to write more competently, rather than relying on macros to make you look better?
    The usefulness of this macro (nice code, btw Fahim) and the utilities I created is that they highlight common writing problems which we often can't see on our own.

    I got the idea for my first macro (Passive Word Highlighter) from my niece who is an English teacher. She will highlight every instance of "was" in a student's paper. I thought, "Hey, I could do that programmatically," and I did.

    When you highlight passive or weak words, you discover how often you use them. It's a real eye-opener. (The first time I ran it against my book, I was appalled by the amount of red on the pages.)

    The interesting thing about this process is that when you spend the time to edit these passive or over-used words and replace them with more robust words, you begin to use them less in your new writing. These utilities DO make you write mor competently..
    --Roger J. Carlson

  8. #8
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    Quote Originally Posted by Roger J Carlson
    (nice code, btw Fahim)
    Thanks And thank you also for your suite of utilities - I'd been meaning to write an adverb highlighter macro for months now but didn't actually do it till I downloaded your utilities :p And as you might have noticed, I've borrowed your error handler, hope you don't mind
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  9. #9
    crazy spec fic writer L M Ashton's Avatar
    Join Date
    Mar 2005
    Location
    I'm not even sure I know anymore...
    Posts
    5,023
    Quote Originally Posted by Roger J Carlson
    The usefulness of this macro (nice code, btw Fahim) and the utilities I created is that they highlight common writing problems which we often can't see on our own.
    Ain't that the truth. Especially if you've been staring at it for months, or this is your fourth or tenth pass through editing. Ugh!
    Quote Originally Posted by Roger J Carlson
    When you highlight passive or weak words, you discover how often you use them. It's a real eye-opener. (The first time I ran it against my book, I was appalled by the amount of red on the pages.)
    Same as when someone else marks your stuff up for errors. Or, at least, that's how it's supposed to work. (*cough* Fahim *cough*)

    Quote Originally Posted by Roger J Carlson
    The interesting thing about this process is that when you spend the time to edit these passive or over-used words and replace them with more robust words, you begin to use them less in your new writing. These utilities DO make you write mor competently..
    Yup. Happens with all forms of active editing. As you replace your weak writing with something stronger, you begin to incorporate it into your first draft, and progressively, as long as you're working on improving your writing, your first drafts get better and better over time.

    I'm working on a fourth first draft right now, and the writing is, by far, much stronger in this first draft than even my second after several rounds of editing. It really makes a difference in quality in the long run.

    This is also, by the way, why I advocate critiquing other people's writing. It trains us to be able to spot errors easier, and after doing that to other people's writing, we begin to more easily see those same problems in our own writing. Critiquing is skewed in that respect - to me, it seems like the one giving the critique is in a position to benefit from giving the critique than the recipient has from getting it.

  10. #10
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    Was checking the highlighting functionality for the macro under Word 2007 today and noticed a couple of issues. I don't know if the first issue was there under versions of Word before 2007, but the wildcard used to find adverbs seems to take more than a word at times. The other issue is that the adverb exception list is case-sensitive and so "Only", "only" and "ONLY" are treated as three different words I've fixed both but no guarantees as to whether the wildcard will work for any versions of Word other than Word 2007.

    Here's what you need to do:

    1. Add "Option Compare Text" on a line by itself before "Sub FAF_WordHighligher()" so it looks like this in the code in the first post:
    Code:
    Option Compare Text
    
    Sub FAF_WordHighlighter()
    '
    ' WordHighlighter Macro
    2. Change the wildcard for adverb matching, which is currently "<[! ]@(ly)>" to "<[! ^13]@(ly)>" so that it looks like this in the code in the first post:
    Code:
    		With rng.Find
    			.Text = "<[! ^13]@(ly)>"
    			.Forward = True
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  11. #11
    Going home! Zelenka's Avatar
    Join Date
    Oct 2007
    Location
    Prague now, Glasgow in November
    Posts
    2,921
    These all look so great. Unfortunately I seem to have something wrong with the installation of my MS Word, as I just keep getting an error message, something to do with the 'visual basic editor' not working.

  12. #12
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    Have you tried repairing your Word installation? What version of Word do you have an what's your version of Windows?
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  13. #13
    Going home! Zelenka's Avatar
    Join Date
    Oct 2007
    Location
    Prague now, Glasgow in November
    Posts
    2,921
    Quote Originally Posted by Fahim View Post
    Have you tried repairing your Word installation? What version of Word do you have an what's your version of Windows?
    I'm ashamed to say I'm still using Word 97 on Windows XP sp2. It seems to be something wrong with the installation disk itself as I've tried reinstalling and it comes up with the same error. I get an error message during installation, something to do with one of the driver files, and then the visual basic editor seems to be messed up somehow because of this.

  14. #14
    Mad coder, lazy writer Fahim's Avatar
    Join Date
    Jan 2006
    Location
    Sri Lanka
    Posts
    1,703
    Hmm ... without knowing the exact error messages during installation, can't really help you much. But I do have a question? When you re-installed, did you install over your existing installation of Word? Or did you try uninstalling Word and then re-installing? Since it's Word 97, I can't recall if it had a repair feature but I suspect not
    "My wife loved the dog. The Martian had it, and everybody knew that Martians loved dogs ... as a delicacy. I should have left them to their love triangle but there I was, chasing after the bombed mutt!"
    Normal Kint, Honest, the Martian Ate Your Dog - humorous science fiction novel available for FREE download!
    Solipsistic Meanderings
    Free software for writers (and others too :p)

  15. #15
    YA romance writer in love with love KarlaErikaCal's Avatar
    Join Date
    Sep 2007
    Location
    Chicago
    Posts
    12,480
    THANKS! It works perfectly! But after I ran it... I sure have loads to work on... Oh well
    BLOG
    TWITTER
    FACEBOOK FAN PAGE
    GOODREADS

    WIPs:
    TATTOO LOVE - 14.8K


  16. #16
    New Fish; Learning About Thick Skin
    Join Date
    Mar 2010
    Posts
    3
    thx you have been really helpfull!

  17. #17
    Disgruntled Scientist dgiharris's Avatar
    Join Date
    Aug 2006
    Location
    Limbo
    Posts
    6,730
    I developed a Spreadsheet for Tracking all of my short stories and articles. It is color coded. I created a generic template that shows how to use the spreadsheet. Within the spreadsheet, just put the cursor over any little red triangle (comments) and a pop-up window will show up with an explanation of the section.

    On the bottom of the spreadsheet you will see different tabs for different sections.

    I loaded the spreadsheet on an online file storage site: www.box.net

    The user name is: dgiharris
    email address is: dgiharris@yahoo.com
    password is: spreadsheet

    it is in a folder titled AW spreadsheet (the only folder)

    go there, download my excel file and enjoy

    Mel...

  18. #18
    practical experience, FTW
    Join Date
    Dec 2009
    Location
    los angeles
    Posts
    119
    I love this!!! I sent it to some writer friends who are published and they loved it. My only suggestion would be to put what each color means at the top of the document. i.e Turquoise (but use the color)= overused words etc... I know you can see it from the code, but everyone I sent it to was a complete computer novice, all that code scared them. They are not going to look at it. great job!

  19. #19
    Dum Spiro, Spero. Gavin23's Avatar
    Join Date
    Aug 2011
    Posts
    186
    Found this really helpful, thanks
    No matter who you are and what you do, one day, we will be nothing more than a forgotten memory.








  20. #20
    practical experience, FTW
    Join Date
    Dec 2009
    Location
    los angeles
    Posts
    119
    how to get this to work in word 2010?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Custom Search