#1
|
|||
|
|||
Select everything not inside quotations
Hi, thanks for having this forum. I have a rather long document with a lot of dialogue. I would like to change it from present tense to past tense. I know I can find and replace words like 'is' with 'was' and change word tense, but I don't want that to happen inside the dialogue. (It makes it pretty much gibberish)
Is there a way to select what's not inside dialogue, then change the tense? Any help is appreciated. Thank you! |
#2
|
||||
|
||||
That's a tall order. Working with a COPY of the document, I would be inclined to use replace to find the quoted sections and highlight them. Then I would create a macro to find the words you want to replace and ignore the replacement if the text is highlighted. Then remove the highlight.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
That sounds like it would work, but I have no idea how to do that. Do you have any suggestions?
I've spent at least eight hours doing find/replace then going back to the dialogue and changing it back, but I'm only on page five out of over 300. It will take me as long to fix it as it did to write it. |
#4
|
||||
|
||||
The dialog part of your request is not particularly difficult but I can't get my head around the hard part of changing tense. Do you have an automated way of doing that?
If we can understand your method for changing tense, we can suggest how to isolate the dialog from that method.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
No, I basically just do Control + F for like space is space then replace with space was space then just do like search for like takes and replace with took or creeps with crept, etc. it takes a long time, but I think if I can get the dialogue not to change, it might be easier. There is a lot of dialogue and it ends up completely gibberish.
I've worked with a couple excel macros before, but it was just recording what I did on the screen. If I had an editable macro I could keep putting words in it I come across? Any help is appreciated. |
#6
|
||||
|
||||
I'm not convinced that doing global searches outside of the quotes is not going to result in gibberish but it is worth a try.
I would start by building a list with the search terms followed by their replace terms is was run ran creep crept do did I can't do a macro right now but if you want to supply a larger list of terms with a sample of your document content then I can have a look at it tomorrow or over the weekend.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#7
|
|||
|
|||
background speculation: would using a separate paragraph style for dialogue make it easier to restrict the scope of search/replace?
|
#8
|
||||
|
||||
The following should do the trick. Create a new document with a two column table (no header row). Put the words to find in the left column, their replacements in the right column. Save it in your My Documents folder as Changes.docx and close it. Then run the following macro on your COPY document. Th macro assumes that your document has straight quotes. If it has English smart quotes then replace
Code:
Chr(34) & "*" & Chr(34) Code:
Chr(147) & "*" & Chr(148) Code:
Sub ReplaceFromTable() Dim oChanges As Document, oTarget As Document Dim oTable As Table Dim oldpart As Range, newpart As Range Dim oRng As Range Dim i As Long Set oTarget = ActiveDocument Set oRng = oTarget.Range With oRng.Find 'find quoted text, assumes straight quotes are used Do While .Execute(findText:=Chr(34) & "*" & Chr(34), MatchWildcards:=True) oRng.HighlightColorIndex = wdTurquoise oRng.Collapse 0 Loop End With 'table document (changes.docx)from My Documents folder Set oChanges = Documents.Open(Environ("USERPROFILE") & "\Documents\changes.docx") Set oTable = oChanges.Tables(1) For i = 1 To oTable.Rows.Count Set oRng = oTarget.Range Set oldpart = oTable.Cell(i, 1).Range oldpart.End = oldpart.End - 1 Set newpart = oTable.Cell(i, 2).Range newpart.End = newpart.End - 1 With oRng.Find Do While .Execute(findText:=oldpart) If Not oRng.HighlightColorIndex = wdTurquoise Then oRng.FormattedText = newpart.FormattedText End If oRng.Collapse wdCollapseEnd Loop End With Next i oChanges.Close wdDoNotSaveChanges oTarget.Range.HighlightColorIndex = wdNoHighlight lbl_Exit: Set oRng = Nothing Set oTarget = Nothing Set oChanges = Nothing Set oTable = Nothing Exit Sub End Sub
__________________
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; 08-27-2020 at 08:48 PM. |
#9
|
||||
|
||||
Bravo on the code Graham, I haven't tested it but I'm pleased someone else had a go at it first.
I was thinking it would be better to tag the dialog with a character style and then apply highlights to the words that get changed - I reckon I would want to review a lot of the changes before I would be confident that you can simply change the tense of individual words without ruining the content.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#10
|
||||
|
||||
I agree, but it's starting point and the intrusion in a large document of the confirmations would soon become tedious. Putting on my hat as a former journalist, I think I would prefer to proof read it after the bulk changes. There is no simple silver bullet for a job like this.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#11
|
|||
|
|||
Hi, guys, thank you both tons. Yes, it will still require proofread and editing but I hope this will reduce the time for that. I'll give it a go :-) Glad I came here, and thanks again!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to apply a style between quotations | WVA | Word VBA | 6 | 07-30-2019 11:13 AM |
How to superscript inside a fraction? | Xifortis | Word | 1 | 12-20-2018 11:42 AM |
Header on Top Of Listbox( Not Inside) | charlesdh | Excel Programming | 2 | 08-30-2018 01:45 PM |
Text inside text boxes create headings inside my table of contents!!! How do I delete the created he | carstj | Word | 3 | 04-11-2016 12:46 PM |
How can you add arrows inside tables? | canthelp | Word | 4 | 11-03-2015 10:48 AM |