Re: string parameters are too long? by Doug
Doug
Wed Jul 16 12:46:59 PDT 2008
Use the following construction:
Dim Detail as Range
Set Detail = 'Range that contains the text that you want to insert
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(Findtext:="<<<Detail>>>", Forward:=True,
MatchWildcards:=False, Wrap:=wdFindStop) = True
Selection.Range.FormattedText = Detail.FormattedText
Loop
End With
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"clara" <clara@discussions.microsoft.com> wrote in message
news:A85793B7-7896-465D-93DE-F211A44DDF8E@microsoft.com...
> Good Morning Doug,
>
> The following is my code snippet. The general meaning: get the text from
> range(details), then replace the <<<Detail>>> in my word doc with the
> text.
> During the replacement, the length of the text is limited below 254, I
> hope
> replacement include all the characters when the text length is over 254.
>
> Detail =Range(Details).Value
>
> With appWrd.Selection.Find
> .text = "<<<Detail>>>"
> With .Replacement
> .text = ActionDetail
> End With
> .Execute Format:=True, Replace:=wdReplaceAll
> End With
>
> thank you so much for your help
>
>
> Clara
>
> "Doug Robbins - Word MVP" wrote:
>
>> The macro that I posted was a workaround for the similar issue of their
>> being a limitation on the length of the information that can be inserted
>> by
>> the use of vba into a formfield in a document that is protected for
>> forms.
>>
>> If you need assistance, you should show us the code that you are trying
>> to
>> use to insert information into what you refer to as "place holders".
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "clara" <clara@discussions.microsoft.com> wrote in message
>> news:A43CD31F-3AAE-45E5-A6FB-03267066B9EC@microsoft.com...
>> > Hi Doug Robbins,
>> >
>> > 254 is the max len allowed. Could you elaborate your code a little
>> > further
>> > ,
>> > especially the line marked with *
>> >
>> > If LenFillText > 255 Then
>> > SecondBit = Mid(FillText, 256, LenFillText - 255)
>> > * ActiveDocument.FormFields("Text1").Result = FirstBit
>> > * Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
>> > * ActiveDocument.Unprotect
>> > * Selection.InsertAfter SecondBit
>> > *ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
>> > Else
>> > ActiveDocument.FormFields("Text1").Result = FillText
>> > End If
>> >
>> >
>> > Clara
>> >
>> > thank you so much for your help
>> >
>> >
>> > "Doug Robbins - Word MVP" wrote:
>> >
>> >> Probably 255 characters.
>> >>
>> >> You may need to do something like:
>> >>
>> >> ' FILIT Macro
>> >> ' Macro created 05/09/98 by Doug Robbins to insert long string into
>> >> FormField
>> >> '
>> >> Dim FillText as String, FirstBit as String
>> >> FillText = "Your long string"
>> >> LenFillText = Len(FillText)
>> >> FirstBit = Left(FillText, 255)
>> >> If LenFillText > 255 Then
>> >> SecondBit = Mid(FillText, 256, LenFillText - 255)
>> >> ActiveDocument.FormFields("Text1").Result = FirstBit
>> >> Selection.GoTo What:=wdGoToBookmark, Name:="Text1"
>> >> ActiveDocument.Unprotect
>> >> Selection.InsertAfter SecondBit
>> >> ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
>> >> Else
>> >> ActiveDocument.FormFields("Text1").Result = FillText
>> >> End If
>> >>
>> >>
>> >> --
>> >> Hope this helps.
>> >>
>> >> Please reply to the newsgroup unless you wish to avail yourself of my
>> >> services on a paid consulting basis.
>> >>
>> >> Doug Robbins - Word MVP
>> >>
>> >> "clara" <clara@discussions.microsoft.com> wrote in message
>> >> news:653CDEFB-405B-4114-B625-624BA46506DE@microsoft.com...
>> >> > Hi all,
>> >> >
>> >> > I define some place holders ( like <<<place holder>>> in a doc file
>> >> > and
>> >> > to
>> >> > replace the place holders with some texts from an excel file. when
>> >> > text
>> >> > length become long then I am told "string parameters are too long",
>> >> > how
>> >> > long
>> >> > is too long and how can I circumvent it ?
>> >> >
>> >> > Clara
>> >> > --
>> >> > thank you so much for your help
>> >>
>> >>
>> >>
>>
>>
>>