View Single Post
 
Old 05-12-2019, 11:41 PM
guwic guwic is offline Windows 10 Office 2013
Novice
 
Join Date: May 2019
Posts: 1
guwic is on a distinguished road
Default Need help to replace a word in word file (macro)

With help a macro i want to substitute all names written with upcase letters with a word with letters following the first in lowcase letters. Here i my code to do this, sometimes it doesn't work, I cannot figure out why, can someone help?

Part of the code, the bold word to replace has been identified

for i =..... to ...
(With ActiveDocument.Words(i))
(skip junk, find net bold name..)
MsgBox = Left(.Text, 1) + LCase(Mid(.Text, 2)) ' changing text works!
.Text = Left(.Text, 1) + LCase(Mid(.Text, 2)) ' but not this!
(End With)
Next

Here i part of my word-document before and after running the macro. Replacing with a fixed string (like "ABC") works (but not very helpful). Of course I've tried a lot of variations without success. Any idea about what is wrong will be welcome.

Before:
Tabell II A1

ELLEN MARGARETA DOROTEA LINDSTRÖM (se tab II) *1863-08-03 i Visby, död 1922 och begr i Pittsburg, USA.



Tabell II A2

IVAN EUGÈNE ANATOLE LINDSTRÖM (se tab II) *1865-02-19 i Visby, död 1927 i Visby, begr i familje¬graven i Visby. Student-ex 1885 i Visby. Genomgick Gymnastiska Central¬institutet i Stockholm 1885-87. Anst såsom sjukgymnast vid Frans Lind¬ströms

After:
Tabell II A1

ELLEN MARGARETA DOROTEA Lindström (se tab II) *1863-08-03 i Visby, död 1922 och begr i Pittsburg, USA.



Tabell II A2

IVAN EUGÈNE ANATOLE Lindström (se tab II) *1865-02-19 i Visby, död 1927 i Visby, begr i familje¬graven i Visby. Student-ex 1885 i Visby. Genomgick Gymnastiska Central¬institutet i Stockholm 1885-87.
Reply With Quote