PDA

View Full Version : Word 2010 Find (but not replace) within Quoted text



kathrynloch
02-28-2014, 07:44 PM
Dammit, Jim, I'm an author not a coder! :help

Hi everyone,

I'm very sorry for having to post this because I know the answer is right under my nose, but my search-fu is weak and despite repeated tries, I'm stuck.

I'm a fiction author and use Word 2010. I write novels, so I have tons of dialogue.

I need to search for common words such as "to" (among others) but only in dialogue - because the word "to" is so common, if I do a general search, OMG - I'll be reading through this stuff forever. If I can narrow down the search to only dialogue it would help a lot. But I haven't found a way to tell word to search between quotation marks.

This can get really overwhelming to try to find manually. I'm trying to come up with a macro that will allow me to find text within quoted text but I can't have an auto replace, I have to look at every instance and decide if my "search term" needs to be changed or not.

I also have my auto correct on so Word changes my quotes to smart quotes.

I did find a code that I thought addressed my issue on a website - (I took out the http since I can't post links)
//word.tips.net/T011638_Finding_Quoted_Text_in_VBA.html

But when I tried it, Word just sat there and looked at me funny. :banghead:

I did an extensive search here, trying to see if I could find something to adapt but to be honest, I've been in editing mode for the past two days and my brains are leaking out of my ears.

I'd really appreciate the help - normally I'm pretty good at figuring out this sort of thing, but I'm striking out and stressing out because my deadline is tomorrow. :crying:

Thanks for your understanding!

Cheers,
Kath

fumei
02-28-2014, 08:37 PM
I am crossing my fingers here, but by chance is the dialogue in its own Style (and of course it should be...)? If it is, then it makes it a bit easier. If not, ummm, a lot harder.

kathrynloch
02-28-2014, 08:52 PM
Actually, it wasn't - but that I can do and just did. ;) So now I have a "dialogue" style.

fumei
02-28-2014, 09:04 PM
Sub FindTo()
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
.Style = "myDialog"
Do While .Execute(findtext:="to", Forward:=True) = True
' do whatever
MsgBox r.Paragraphs(1).Range.Text
Loop
End With
End Sub just as an example, if all your dialogue uses the myDialog Style - and remember it could look exactly like the other text - the above:

1. looks for only that Style
2. only returns the paragraph with that Style if it contains "to".

Then you can do whatever it is you need to do. In the above example it just displays the paragraph.

fumei
02-28-2014, 09:06 PM
So perhaps post an example of what you want to do if you find dialogue with a "to".

kathrynloch
02-28-2014, 10:30 PM
Okay - I just freaked my poor little laptop out big time. lol! Hang on and let me get it sorted. ;)

kathrynloch
02-28-2014, 10:53 PM
Okay - basically, I'm looking for dialect changes that I missed within character dialogue. For example, normal dialogue: "Go to the barn." But if I have dialect, "Go tae the barn." Now just searching the word "to" is crazy because it's used so much in narrative and in dialogue. But because not all of my characters speak the same dialect, I can't do a global find and replace I have to check the dialogue before I decide if it needs to be changed.

There - clear as mud, huh? lol! Thanks for helping me, I really appreciate it.

macropod
02-28-2014, 11:30 PM
In that case, perhaps you should consider creating separate Styles for each of the dialogue dialects/variants; then you can choose which variant to use in the Find/Replace. Having the different Styles will also help you keep track of who said what & when.

kathrynloch
02-28-2014, 11:37 PM
In that case, perhaps you should consider creating separate Styles for each of the dialogue dialects/variants; then you can choose which variant to use in the Find/Replace. Having the different Styles will also help you keep track of who said what & when.

That's a fantastic idea! Unfortunately, with my deadline about to pounce on me, I won't be able to do it with this manuscript. I'll just muddle through this one as best I can, then I can set up my next one properly. I've got yet another novel due to my editor in April. The hits just keep on comin'! ;)

But that way I have the code and the styles I need and I won't be running around willy nilly.

Thank you so much fumei and macropod

fumei
03-01-2014, 04:43 PM
As a general rule, if there is something truly distinctive about a type of text- including text that has the same format, but different context - it makes it a whole lot easier to have Styles for them. So yes, macropod's suggestion is the way a lot of writers work. For precisely the reason you are asking about, having a separate Style for a dialect is a good idea.