View Single Post
 
Old 11-21-2019, 02:59 AM
irinarox irinarox is offline Windows 10 Office 2016
Novice
 
Join Date: May 2019
Posts: 9
irinarox is on a distinguished road
Default Word Macro give errror that string is too long - how to fix it

Hi guys,


I am trying to write a Macro to replace a string of text with another one, but I receive an error for the text to replace - run time error 5854 - string parameter is too long. I know that the string has more than 255 characters, but I cannot change it and I cannot split it in 2 commands.



Code it like below:
Let Address2 = "{Insert shop address}"
Let Localizedaddress1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxx xxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = Address2
.Replacement.Text = Localizedaddress1
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll


Can you please help with how should I modify it in order to work?


Thank you!
Irina
Reply With Quote