#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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?
|
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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.
|
#5
|
|||
|
|||
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." |
#6
|
|||
|
|||
Good! It's much better! So, every surname follows 'Vgl. '. This simplifies the task. Wait a little for the code.
|
#7
|
|||
|
|||
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 |
#8
|
|||
|
|||
Thx a lot! I will give it a try.
|
#9
|
|||
|
|||
I've tested it, but no one is perfect.
|
#10
|
|||
|
|||
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! |
#11
|
|||
|
|||
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 |
#12
|
|||
|
|||
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 |
#13
|
|||
|
|||
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 |
#14
|
|||
|
|||
Quote:
|
#15
|
|||
|
|||
You are welcome!
|
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 |