View Single Post
 
Old 12-01-2023, 06:09 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
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

That document is showing citations put in by a third party tool called Mendeley. This doesn't appear to use the built-in Microsoft citations feature and that is why the macro has no effect in that particular file.

So before developing an all-new solution for your problem, you should first determine whether the tool that created those 'citations' has a capability to perform the change that you require. If it doesn't then a completely different macro would need to work through the content controls that Mendeley has put there. This macro appears to work on your sample
Code:
Sub MoveMendeleyCitations()
  Dim aCC As ContentControl, aRng As Range
  For Each aCC In ActiveDocument.ContentControls
    If aCC.Tag Like "MENDELEY_CITATION*" Then
      Set aRng = aCC.Range
      aRng.Start = aRng.Start - 2
      aRng.End = aRng.End + 1
      Do While aRng.Characters.First = " "
        aRng.Start = aRng.Start - 1
      Loop
      aRng.Select
      If aRng.Characters.First Like "[?!:;.]" Then
        aRng.InsertAfter aRng.Characters.First
        aRng.Characters.First.Delete
        If aRng.Characters.First <> " " Then aRng.InsertBefore " "
      End If
    End If
  Next aCC
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote