Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2017, 06:20 AM
Macsen Macsen is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2016
Novice
Move full stops to other end of a citation
 
Join Date: Jun 2017
Location: Wales
Posts: 5
Macsen is on a distinguished road
Lightbulb 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
Reply With Quote
  #2  
Old 07-03-2017, 05:23 AM
Macsen Macsen is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2016
Novice
Move full stops to other end of a citation
 
Join Date: Jun 2017
Location: Wales
Posts: 5
Macsen is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 07-03-2017, 01:19 PM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2013
Moderator
 
Join Date: Aug 2011
Posts: 3,903
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

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
Reply With Quote
  #4  
Old 07-03-2017, 05:04 PM
Guessed's Avatar
Guessed Guessed is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #5  
Old 07-04-2017, 05:10 AM
Macsen Macsen is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2016
Novice
Move full stops to other end of a citation
 
Join Date: Jun 2017
Location: Wales
Posts: 5
Macsen is on a distinguished road
Default

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'.
Reply With Quote
  #6  
Old 07-04-2017, 02:09 PM
Macsen Macsen is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2016
Novice
Move full stops to other end of a citation
 
Join Date: Jun 2017
Location: Wales
Posts: 5
Macsen is on a distinguished road
Default

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.
Reply With Quote
  #7  
Old 07-04-2017, 04:28 PM
Guessed's Avatar
Guessed Guessed is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
In my version of Word 2016, the citations are all fields inside Content Controls. The CCs add a level of complexity that require extra lines of code to move the ranges. If your document doesn't also have the CCs then you may need to adjust the macro slightly to work.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #8  
Old 07-04-2017, 05:34 PM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2013
Moderator
 
Join Date: Aug 2011
Posts: 3,903
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

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
Reply With Quote
  #9  
Old 07-04-2017, 05:39 PM
Guessed's Avatar
Guessed Guessed is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #10  
Old 07-04-2017, 05:49 PM
Stefan Blom's Avatar
Stefan Blom Stefan Blom is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2013
Moderator
 
Join Date: Aug 2011
Posts: 3,903
Stefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to allStefan Blom is a name known to all
Default

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
Reply With Quote
  #11  
Old 07-04-2017, 10:42 PM
macropod's Avatar
macropod macropod is offline Move full stops to other end of a citation Windows 7 64bit Move full stops to other end of a citation Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #12  
Old 07-05-2017, 02:58 AM
Macsen Macsen is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2016
Novice
Move full stops to other end of a citation
 
Join Date: Jun 2017
Location: Wales
Posts: 5
Macsen is on a distinguished road
Default

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!
Reply With Quote
  #13  
Old 07-05-2017, 03:24 PM
macropod's Avatar
macropod macropod is offline Move full stops to other end of a citation Windows 7 64bit Move full stops to other end of a citation Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #14  
Old 06-27-2023, 12:16 AM
kelstar kelstar is offline Move full stops to other end of a citation Windows 10 Move full stops to other end of a citation Office 2021
Novice
 
Join Date: Jun 2023
Posts: 1
kelstar is on a distinguished road
Default 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:
Originally Posted by macropod View Post
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
Reply With Quote
  #15  
Old 11-30-2023, 07:04 PM
deepapme@gmail.com deepapme@gmail.com is offline Move full stops to other end of a citation Windows 11 Move full stops to other end of a citation Office 2021
Novice
 
Join Date: Nov 2023
Posts: 3
deepapme@gmail.com is on a distinguished road
Default 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
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Move full stops to other end of a citation Word 2014: WPerfect 6.x full-justification "stops working" dan_1 Word 12 01-24-2017 12:43 PM
Move full stops to other end of a citation Insert Citation truepharaoh Word 3 12-03-2016 01:35 AM
Move full stops to other end of a citation How to display the full citation in footnotes/endnotes chakyt22 Word 1 09-29-2015 03:37 AM
Move full stops to other end of a citation Why are full stops appearing in between every word I type?? richards_jacqui@sky.com Outlook 1 04-01-2015 10:40 PM
Move full stops to other end of a citation Citation within a Caption Wes Word 1 05-29-2012 10:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:50 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft