Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2024, 06:11 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default Find Names in Word document – solution? Help.

Hello everyone,



I am new here and quite inexperienced with such topics. I'm generally comfortable with Word, but I've run into the problem that I haven't formatted the last names of the authors correctly in a longer scientific paper. Now I need some help. Is there a way, a chatgpt integration, VBA etc., to find names in a Word document and then reformat them?

Thanks for the help and sorry for my probably naive question, best regards
Landro
Reply With Quote
  #2  
Old 01-19-2024, 07:45 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi! A general answer to a general question: yes, there's a way to find and format names in Word. What's next? Sorry, but you are not specific. What do you mean by "name" and how are you going to reformat the found names?
Reply With Quote
  #3  
Old 01-19-2024, 07:48 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

Hi Vivika,

thanks for the reply.

My aim would be to set all the author references in small caps (in italics if necessary) for a Word document that has approx. 300 pages - and if possible automatically, so that I don't have to enter them individually. What would be necessary for this? Or what would be the most elegant way?

I hope this is more specific. Thanks in advance
Reply With Quote
  #4  
Old 01-19-2024, 07:50 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Could you post at least one reference with name(s). A macro (quite simple) would find words started with a capital letter & change them to all caps. Problem: if a word that is not a name starts a sentence can also be treated as a name. The macro should need more signs of a name to exclude false hits. That's why your sample would be helpful.
Reply With Quote
  #5  
Old 01-19-2024, 07:52 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

Sure thing. It's in german:
"vgl. Schlögl, Rudolf: Politik beobachten. Öffentlichkeit und Medien in der Frühen Neuzeit, in: Zeitschrift für historische Forschung (35), 2008, S. 581–616".
But also:
"Vgl. Bernsee (2017), S. 172."
Reply With Quote
  #6  
Old 01-19-2024, 07:59 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Good! It's much better! So, every surname follows 'Vgl. '. This simplifies the task. Wait a little for the code.
Reply With Quote
  #7  
Old 01-19-2024, 08:50 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Landrob1, here you are:
Code:
Sub Authors()
'Format all surnames (found according to their specific signs) in the selected range.

Dim rng As range
    Application.ScreenUpdating = False
    Set rng = selection.range
    With rng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "[Vv]gl. <[A-Z][!A-Z][a-z]@>"
        .Forward = True
        .MatchWildcards = True
        .Wrap = wdFindStop
        While .Execute
            rng.MoveStart unit:=wdCharacter, count:=5
            rng.Font.Italic = True
            rng.Font.AllCaps = True
            rng.Collapse wdCollapseEnd
        Wend
    End With
    Application.ScreenUpdating = True
    Set rng = Nothing
 End Sub
Note that the macro works on the selected range. As to me, it's more flexible than 'ActiveDocument.range'. A tip: to select a whole doc, press Ctrl+A.
Reply With Quote
  #8  
Old 01-19-2024, 08:59 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

Thx a lot! I will give it a try.
Reply With Quote
  #9  
Old 01-19-2024, 09:01 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

I've tested it, but no one is perfect.
Reply With Quote
  #10  
Old 01-20-2024, 08:19 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

Hello again,
worked wonderfully, but does not help in every case, which was clear
What would a code look like that searches for names from a provided in a Word document and then sets them in small caps.
So if I have the following names:
Ackermann
Angermann
Andersen
Atzeni
Baecker
Ortmann
...
What would that look like?
Many thanks in advance!
Reply With Quote
  #11  
Old 01-20-2024, 09:21 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi! I've changed one line for small caps:
Code:
Sub Authors()
'Format all surnames (found according to their specific signs) in the selected range.

Dim rng As range
    Application.ScreenUpdating = False
    Set rng = selection.range
    With rng.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .text = "[Vv]gl. <[A-Z][!A-Z][a-z]@>"
        .Forward = True
        .MatchWildcards = True
        .Wrap = wdFindStop
        While .Execute
            rng.MoveStart unit:=wdCharacter, count:=5
            rng.Font.Italic = True
            rng.Font.SmallCaps = True
            rng.Collapse wdCollapseEnd
        Wend
    End With
    Application.ScreenUpdating = True
    Set rng = Nothing
 End Sub
The code woarks for all names (including those in the list) if they are preceded by 'V/vgl. '. If you have a problem, please, post a sample. I can suggest that there's more than one space before the "faulty" surnames.
Reply With Quote
  #12  
Old 01-20-2024, 09:26 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

Hey, thanks!
But I think I expressed myself in a misleading way. I was referring to a different code. It should search for all names in a list in the corresponding Word document and then set them in small caps. I hope that's clearer now ...
I would have tried the following, but it doesn't work.

THX!!!

Sub FormatAuthorNamesInSmallCaps()
Dim authorNames As Variant
Dim rng As Range
Dim name As Variant

' Liste der Autorennamen
authorNames = Array("Ackermann", "Angermann", "Andersen", "Atzeni", "Baecker", "Ortmann", "Zamoyski", "Ziegler", "Wurzbach", "Zittel", "Zürcher", "Zytphen-Adeler")

Application.ScreenUpdating = False
Set rng = ActiveDocument.Range

For Each name In authorNames
With rng.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = name
.Replacement.Text = name
.Forward = True
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
If .Found Then
rng.Font.SmallCaps = True
End If
End With
rng.SetRange Start:=ActiveDocument.Range.Start, _
End:=ActiveDocument.Range.End
Next name

Application.ScreenUpdating = True
End Sub
Reply With Quote
  #13  
Old 01-20-2024, 10:05 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

This seems to work:
Code:
Sub FormatAuthorNamesInSmallCaps()

Dim rng As range
Dim authorNames As Variant

Application.ScreenUpdating = False
    Set rng = ActiveDocument.range

'Liste der Autorennamen
    authorNames = Array("Ackermann", "Angermann", _
    "Andersen", "Atzeni", "Baecker", "Ortmann", _
    "Zamoyski", "Ziegler", "Wurzbach", "Zittel", _
    "Zürcher", "Zytphen-Adeler")

    For i = 0 To UBound(authorNames)
        With rng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .text = authorNames(i)
            .Forward = True
            .Wrap = wdFindStop
            .MatchWholeWord = True
            While .Execute
                rng.Font.Italic = True
                rng.Font.SmallCaps = True
                rng.Collapse wdCollapseEnd
            Wend
        End With
    Next i
Application.ScreenUpdating = True
End Sub
Reply With Quote
  #14  
Old 01-20-2024, 10:11 AM
landrob1 landrob1 is offline Mac OS X Office 2016 for Mac
Novice
 
Join Date: Jan 2024
Posts: 9
landrob1 is on a distinguished road
Default

Quote:
Originally Posted by vivka View Post
This seems to work:
Code:
Sub FormatAuthorNamesInSmallCaps()

Dim rng As range
Dim authorNames As Variant

Application.ScreenUpdating = False
    Set rng = ActiveDocument.range

'Liste der Autorennamen
    authorNames = Array("Ackermann", "Angermann", _
    "Andersen", "Atzeni", "Baecker", "Ortmann", _
    "Zamoyski", "Ziegler", "Wurzbach", "Zittel", _
    "Zürcher", "Zytphen-Adeler")

    For i = 0 To UBound(authorNames)
        With rng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .text = authorNames(i)
            .Forward = True
            .Wrap = wdFindStop
            .MatchWholeWord = True
            While .Execute
                rng.Font.Italic = True
                rng.Font.SmallCaps = True
                rng.Collapse wdCollapseEnd
            Wend
        End With
    Next i
Application.ScreenUpdating = True
End Sub
Thx a lot!!!!
Reply With Quote
  #15  
Old 01-20-2024, 10:24 AM
vivka vivka is offline Windows 7 64bit Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

You are welcome!
Reply With Quote
Reply

Tags
chatgpt, names, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing list of names in a publisher or word document Marcia Word 2 09-27-2018 01:28 AM
How to find CAPITALIZED names and change them into small caps dylan.ve Word VBA 5 02-25-2016 03:15 PM
Find and replace inside strings containing various names audioman Word VBA 4 03-25-2014 11:19 AM
Word Form / VBA Solution for Formatted Document elmousa68 Word VBA 5 10-15-2013 05:10 PM
find author names in text anil3b2 Word 0 08-02-2010 04:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:20 AM.


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