#1
|
|||
|
|||
macro problems
I found a macro and copied it into the VBA macro part of microsoft word. It highlighed the telling words in my manuscript well. When I tried to edit the macro by adding more telling words, using the same syntax, it wouldn't work. I had to replace to original to make it work. I copied and pasted a second macro and it highlighted all my vague words well, but when I wanted to use the macro for telling words again, it wasn't there. I saved both macros under all active templates and documents and the normal template as the instructions on the web sites and you tube sites suggested. I want to create other macros based on the one that works and save them so they are available every time I need them. I'm very new to macros and need to learn as much as I can. I'll be eternally grateful to anyone who can help. Thank you. LittleScribbler |
#2
|
||||
|
||||
If you don't post the code and the modifications you have tried to make to it, how can we advise how to correct it?
In the meantime the table replacement options of https://www.gmayor.com/document_batch_processes.htm will undoubtedly do what you require.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com Last edited by gmayor; 03-21-2021 at 03:45 AM. |
#3
|
|||
|
|||
Hi
Thank you Graham for the suggestion. Here is the macro I adapted from one off the internet. It still doesn't work. The only changes I made was the name of the macro and the words I added. I do hope you, or one of the group can tell me where I've gone wrong. I want to run this macro in word documents. LittleScribbler Code:
Sub FillerWords() ' Highlights filler words ' ' Dim range As range Dim i As Long Dim TargetList TargetList = Array("admit", "all off", "as being", "as to whether", "as yet", "care about", "go on", "grateful every day", "if you need to", "if you want", "if you wish", "if you would like to", "I might add", "in terms of", "in my opinion", "in spite of that fact that", "in the event of", "in the event that", "in the process of", “it seems like”, “made it to”, “pick out”, “pick up on”, “play up”, “point out”, “put off”, “put together”, “really”, “spend”, “take action to”, “takes up”, “taking up”, “talk about”, “the most important thing is to”, “the reason”, “time and again”, “took up”, “try to figure out”, “went back over”, “when it comes to”, “which is”, “who is”, “will be different”, “you can”, “you’re going to”, “you’re going to have”, “you’re going to need to”, “in general”, “mostly”, “sort of”, “virtually”, “often”, “I think”, “absolutely”, “definitely”, “very”, “totally”, “literally”, “just”, “ironically”, “truly”, “actually”, “basically”, “to know”, “I see”, “I feel”, “I hear”, “I can feel”, “almost”, “all of”, “factor”, “for all intents and purposes”, “for the most part”, “for the purpose of”, “harder than it has to be”, “individual”, “initial”, “on a regular basis”, “the first step is to”, “time and time again”, “with reference to”) For i = 0 To UBound(TargetList) Set range = ActiveDocument.range With range.Find .Text = TargetList(i) .Format = True .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Do While .Execute(Forward:=True) = True range.HighlightColorIndex = wdPink Loop End With Next End Sub Last edited by macropod; 03-24-2021 at 06:04 PM. Reason: Added code tags & formatting |
#4
|
||||
|
||||
There are multiple problems with your code, above all, the liberal use of smart quotes in the array. The structure is also poor. Try:
Code:
Sub FillerWords() Application.ScreenUpdating = False Dim i As Long, h As Long, TargetList h = Options.DefaultHighlightColorIndex: Options.DefaultHighlightColorIndex = wdPink TargetList = Array("admit", "all off", "as being", "as to whether", "as yet", "care about", "go on", _ "grateful every day", "if you need to", "if you want", "if you wish", "if you would like to", _ "I might add", "in terms of", "in my opinion", "in spite of that fact that", "in the event of", _ "in the event that", "in the process of", "it seems like", "made it to", "pick out", "pick up on", _ "play up", "point out", "put off", "put together", "really", "spend", "take action to", "takes up", _ "taking up", "talk about", "the most important thing is to", "the reason", "time and again", "took up", _ "try to figure out", "went back over", "when it comes to", "which is", "who is", "will be different", _ "you can", "you’re going to", "you’re going to have", "you’re going to need to", "in general", "mostly", _ "sort of", "virtually", "often", "I think", "absolutely", "definitely", "very", "totally", "literally", _ "just", "ironically", "truly", "actually", "basically", "to know", "I see", "I feel", "I hear", _ "I can feel", "almost", "all of", "factor", "for all intents and purposes", "for the most part", _ "for the purpose of", "harder than it has to be", "individual", "initial", "on a regular basis", _ "the first step is to", "time and time again", "with reference to") With ActiveDocument.Content.Find .Format = False .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Replacement.Text = "^&" .Replacement.Highlight = True For i = 0 To UBound(TargetList) .Text = TargetList(i) .Execute Replace:=wdReplaceAll Next End With Options.DefaultHighlightColorIndex = h Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
||||
|
||||
Along with Paul's corrections, I would also expect problems with a single line of VBA growing beyond limits. You can reduce the likelihood of that being an issue by simplifying the quote marks and concatenating chunks into separate lines.
Code:
Sub FillerWords() ' Highlights filler words Dim i As Long, sList As String, TargetList() As String sList = "admit|all off|as being|as to whether|as yet|care about|go on|grateful every day|if you need to|" sList = sList & "if you want|if you wish|if you would like to|I might add|in terms of|in my opinion|" sList = sList & "in spite of that fact that|in the event of|in the event that|in the process of|it seems like|" sList = sList & "made it to|pick out|pick up on|play up|point out|put off|put together|really|spend|take action to|" sList = sList & "takes up|taking up|talk about|the most important thing is to|the reason|time and again|took up|" sList = sList & "try to figure out|went back over|when it comes to|which is|who is|will be different|you can|" sList = sList & "you're going to|you're going to have|you're going to need to|in general|mostly|sort of|virtually|" sList = sList & "often|I think|absolutely|definitely|very|totally|literally|just|ironically|truly|actually|basically|" sList = sList & "to know|I see|I feel|I hear|I can feel|almost|all of|factor|for all intents and purposes|for the most part|" sList = sList & "for the purpose of|harder than it has to be|individual|initial|on a regular basis|the first step is to|time and time again|with reference to" TargetList = Split(sList, "|") Options.DefaultHighlightColorIndex = wdPink With ActiveDocument.Content.Find .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Wrap = wdFindContinue .ClearFormatting .Replacement.ClearFormatting .Replacement.Highlight = True For i = LBound(TargetList) To UBound(TargetList) .Text = TargetList(i) .Execute Replace:=wdReplaceAll Next End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia Last edited by Guessed; 03-24-2021 at 09:15 PM. Reason: Fixed spelling mistake 'simplying' |
#6
|
||||
|
||||
True, but that isn't an issue with the OP's code warranting such an approach.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
||||
|
||||
You may be right but I read the initial post as saying that was exactly the problem...
Quote:
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#8
|
||||
|
||||
I'd suggest that was because those "more telling words" were bounded by smart quotes instead of plain quotes. Everything after "in the process of" was bounded by smart quotes.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Hi
Thank you everyone who has helped me with this macro problem. I haven't learnt batch files yet, but would love to Graham The rewritten macros from macropod, Paul Edstein and Guessed worked. Thank you so much. I'm delighted. For macropod and Paul Edstein, I didn't know what smart quotes were, but think I might now after reading all the feedbacks again. I still don't know what poor structure, stucture code or code tags are. I can see the hash mark at the top now and never knew what it was for, but I'll press it before I sent this message and hope the message still gets through. For guessed, is there a limit to the amount of words I can use in a macro? LittleScribbler |
#10
|
||||
|
||||
Quote:
Lots of VBA functions have their own limits, though. Hence Find/Replace has a 255-character limit for each expression.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?] | Le_Blanc | Word VBA | 10 | 03-22-2021 11:38 AM |
Problems with Macro for inserting autotext when autotext name isn't followed by a space | amz1950 | Word VBA | 0 | 02-14-2018 10:20 AM |
Macro problems with Word for Mac 2016 16.9.1 | JML | Word VBA | 2 | 02-03-2018 01:14 PM |
Spell check macro within macro button field doesn't work in one document | samuelle | Word VBA | 0 | 07-20-2016 02:27 AM |
Cutting and Pasting and Macro problems in Excel 2010 | enkel | Excel Programming | 3 | 01-02-2012 10:15 PM |