#1
|
|||
|
|||
Move full stops to other end of a citation
Hi All,
I've written a 167,000-word academic document. It's all ready to go but I've just been told that I need to change one minor detail: the full stops are on the wrong side of the citations! At the moment I have: sentence. (CITATION) What I need is: sentence (CITATION). Unfortunately, as there are over a thousand citations in the document it would take an awfully long time to go through and change them all. I had presumed that this would be a case of an easy find/replace, but I'm not sure what represents a citation in find/replace. The citations look something like this when field codes are on: {CITATION Cur78 \p 63 \1 2057} If anyone could help me I would be very, very grateful! Best, Ifan |
#2
|
|||
|
|||
Hi NC Training Services. Thanks for the reply.
I understand how to use Advanced Find but there doesn't seem to be anything under Special that actually represents Citations. |
#3
|
||||
|
||||
A wildcard find and replace would seem appropriate here, but (as far as I know) you can't do that and manipulate field codes at the same time.
With a bit of luck, someone will be able to suggest a macro that does the job.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#4
|
||||
|
||||
Do you need to actually know that it is a citation or can you just use the 'period space (' as your trigger? Are there cases where this pattern doesn't involve a citation?
For instance, you could do a wildcard search and replace to move the period which precedes an open bracket by searching for .{space}(\(*\)) and replacing it with {space}\1. Note that the {space} should be an actual space.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Thanks for the reply Guessed.
I've tried this in the past but I receive a message that says 'The Find What text contains a pattern match expression which is not valid'. |
#6
|
|||
|
|||
Aha, the error message doesn't come up if I replace {space} with an actual space!
However this does nothing for the citations, which are put in using References -> Insert citation. (\(*\)) doesn't seem to find those. |
#7
|
||||
|
||||
I've done some testing and worked out the find/replace doesn't seem possible so I think a macro solution is going to be required.
Code:
Sub RelocateCitations() Dim aFld As Field, aRng As Range For Each aFld In ActiveDocument.Fields If InStr(1, LCase(aFld.Code), "citation") Then Set aRng = aFld.Result aRng.Collapse wdCollapseStart aRng.MoveEnd Unit:=wdCharacter, Count:=-1 'to get in front of CC aRng.MoveStart Unit:=wdCharacter, Count:=-2 If aRng.Text = ". " Then aRng.Text = " " Set aRng = aFld.Result aRng.Collapse wdCollapseEnd aRng.MoveStart Unit:=wdCharacter, Count:=2 'to get after CC aRng.InsertAfter "." End If End If Next aFld End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#8
|
||||
|
||||
Did you get this to work on your system? Here, the asterisk fails to find fields.
Your search expression works just fine when there is ordinary text inside the braces.
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#9
|
||||
|
||||
Stefan
No, when I tested it with real citations it wasn't getting any hits and searching for "^d Citation" wasn't working for me either (when I included the {period}{space} so in the end I decided it needed a macro solution.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#10
|
||||
|
||||
That macro looks promising. I tried working with ranges, with no success here. :-)
__________________
Stefan Blom Microsoft Word MVP Microsoft 365 apps for business Windows 11 Professional |
#11
|
||||
|
||||
Try:
Code:
Sub Demo() Application.ScreenUpdating = False ActiveWindow.View.ShowFieldCodes = True With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "^d CITATION" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute End With Do While .Find.Found .Start = .Start - 1 .MoveStartWhile " ", -1 .Start = .Start - 1 If .Characters.First Like "[?!:;.]" Then .End = .End + 1 .InsertAfter .Characters.First With .Duplicate .Collapse wdCollapseStart .MoveEndWhile " ", 1 .Delete End With End If .Collapse wdCollapseEnd .Find.Execute Loop End With ActiveWindow.View.ShowFieldCodes = False Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
Brilliant, that seems to have worked like a charm. You've just saved me having to manually delete and insert around 1500 full stops! Thank you very much.
One last questions: Is there a way of making the macro apply to footnotes as well? All the citations in the main body of the document have been changed but those in the footnotes remain the same. Thanks! |
#13
|
||||
|
||||
Try:
Code:
Sub FixRefs() Application.ScreenUpdating = False ActiveWindow.View.ShowFieldCodes = True With ActiveDocument Call FndRep(.Range) Call FndRep(.StoryRanges(wdEndnotesStory)) Call FndRep(.StoryRanges(wdFootnotesStory)) End With ActiveWindow.View.ShowFieldCodes = False Application.ScreenUpdating = True End Sub Sub FndRep(Rng As Range) With Rng With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "^d CITATION" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute End With Do While .Find.Found .Start = .Start - 1 .MoveStartWhile " ", -1 .Start = .Start - 1 If .Characters.First Like "[?!:;.]" Then .End = .End + 1 .InsertAfter .Characters.First With .Duplicate .Collapse wdCollapseStart .MoveEndWhile " ", 1 .Delete End With End If .Collapse wdCollapseEnd .Find.Execute Loop End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#14
|
|||
|
|||
Hi Macropod - I would really appreciate your help
Hi there,
Macropod provided code back in 2017 to somebody that needed to change the placement of the references in relation to the full stops (as below). I am need of the opposite alteration to the original i.e., my references currently sit before the full stops but need to be transferred to after the full stop. I'm sure anyone that wasn't as oblivious to coding as me could alter the original code provided by Macropod, but this isn't me. Any help would be greatly appreciated and save me days of work and frustration. Quote:
|
#15
|
|||
|
|||
Citation
Hello,
I saw there is a post regarding the full stop citation change. At the moment I have: sentence. (CITATION) What I need is: sentence (CITATION). But the code I saw here is not working in my case. Your help will be appreciated. Thanks |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word 2014: WPerfect 6.x full-justification "stops working" | dan_1 | Word | 12 | 01-24-2017 12:43 PM |
Insert Citation | truepharaoh | Word | 3 | 12-03-2016 01:35 AM |
How to display the full citation in footnotes/endnotes | chakyt22 | Word | 1 | 09-29-2015 03:37 AM |
Why are full stops appearing in between every word I type?? | richards_jacqui@sky.com | Outlook | 1 | 04-01-2015 10:40 PM |
Citation within a Caption | Wes | Word | 1 | 05-29-2012 10:29 AM |