Hi,
I've got a few lines of code which find some placeholders on a Word document i.e. <<name>> and then it replaces that placeholder with a cell within Excel.
The issue is that the string length can be quite large and bigger than the 256-character max length.
I use this sub to action the replacement:
Sub ReplaceText(ByRef wdoc As Object, ByVal placeholder As String, ByVal replacement As String, ByVal count As Long)
' This is the code to be recalled for each replacement throughout thedoc creators
Dim i As Long
For i = 1 To count
With wdoc.Content.Find
.Text = placeholder
.replacement.Text = replacement
.Execute Replace:=2
End With
Next i
End Sub
I've underlined the line which gets highlighted in the DEBUG. Is there a work around so that I can make the replacement work for longer texts.
The search and replacement in the actual sub is below:
ReplaceText wdoc, "<<description>>", Sheet22.Cells(r, 6).Text, 2
This is the only line really that will keep popping up this error, but it would be ideal if we could get it to work for all the replacements just in case. Hope that helps.
Thanks in advance for any help.