[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Word.Range.Find.Execute Replace String too Long

Posted on 2003-11-04
3
Medium Priority
?
1,022 Views
Last Modified: 2012-08-13
Hi,
I am doing the following

            'A very long string length ~ 700
            strResponse = "abc................................."
            rngTemplate.Find.Text = "<<Text>>"
            rngTemplate.Find.Replacement.Text = strResponse
            rngTemplate.Find.Execute Replace:=wdReplaceOne
           
I get an error when i assign the template, the strResponse Text...The reason beign that its too long. The strResponse in my prgm will always be very long. Please help on how to insert a long string into a template at a specific position.

Thank you!
0
Comment
Question by:jainpriyanka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
NBrownoh earned 375 total points
ID: 9682236
break the string down to acceptable lengths and use a for loop do input the string instead of trying to do it all at once.

kind like this

Do While len(VeryLongString) > 0
            if len(VeryLongString) >  251 then
                   strResponse = mid(VeryLongString, 1, 250) & "<<Text>>"
                   VeryLongString = mid(VeryLongString, 251)
            else
                   strResponse = VeryLongString
            end if
            rngTemplate.Find.Text = "<<Text>>"
            rngTemplate.Find.Replacement.Text = strResponse
            rngTemplate.Find.Execute Replace:=wdReplaceOne
loop
0
 
LVL 7

Expert Comment

by:_agj_
ID: 9684372
what about

            set wrd = rngTemplate.Find( "<<Text>>")
            wrd.replace strResponse

           or

          set wrd = rngTemplate.Find( "<<Text>>")
          wrd(1) = strResponse.
0
 
LVL 3

Expert Comment

by:NBrownoh
ID: 9688299
crap man, i hate putting errors in my code, seems to be happening a lot lately, probably should get to bed sooner :)

after the else, if you have a string that is less than 251 characters that code will never end, so put this line in before then end if
VeryLongString = ""

and, glad i could help you out.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question