![]() |
|
|
|
#1
|
||||
|
||||
|
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] |
|
#2
|
||||
|
||||
|
deepapme
The code from #14 on this thread works on my machine. You could post a sample document that the code doesn't work on if you want a quick answer otherwise we can go through a series of steps to find out what you actually have in your document.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#3
|
||||
|
||||
|
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 |
|
#4
|
|||
|
|||
|
Thanks a lot. That works like a magic. I am grateful to you!!
|
|
| Thread Tools | |
| Display Modes | |
|
|
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 |