lostweekend
New Member
- Joined
- Aug 25, 2016
- Messages
- 7
Hi,
I'm trying to run a relatively simple excel to word text replace but several of my strings are over 255 characters. So far, none of the work arounds Ive attempted have panned out but I'm I dont work with VBA very frequently and am pretty clueless. Can a work around be accomplished here? My code is copied below.
I'm trying to run a relatively simple excel to word text replace but several of my strings are over 255 characters. So far, none of the work arounds Ive attempted have panned out but I'm I dont work with VBA very frequently and am pretty clueless. Can a work around be accomplished here? My code is copied below.
Code:
'Sub TextReplace()
Dim path As String
Dim oCell As Integer
Dim from_text As String, to_text As String
Dim WA As Object
'Set path to template
path = "C:\Users\100156\Desktop\Tester.docx"
Set WA = CreateObject("Word.Application")
WA.Documents.Open (path)
WA.Visible = True
For oCell = 1 To 10
from_text = Sheet1.Range("C" & oCell).Value
to_text = Sheet1.Range("D" & oCell).Value
With WA
.Activate
With .Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = from_text
.Replacement.Text = to_text
.Execute Replace:=wdReplaceAll
End With
End With
Next