+ Reply to Thread
Results 1 to 5 of 5

Search a sting in word doc with more than 255 chars

  1. #1
    Registered User
    Join Date
    12-14-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question Search a sting in word doc with more than 255 chars

    Hi,

    Is there any way to create a macro which can search a string with string length more than 255 chars? Also is there any way to know if a word has been replaced in text file, like in a doc i have word "abcdis1234" and if i am searching for a word "is" in the same document, it should show me message as "Not Found". I tried using .MatchWholeWord and then .Find.Found = "true", but still it is showing me message as "Found" which should not happen, but the text is not replaced...

    Shankha
    Last edited by shankha_29; 12-14-2012 at 03:38 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Search a sting in word doc with more the 255 chars

    You can use InStr to find a substring within string.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-14-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Search a sting in word doc with more the 255 chars

    ok will try that.... but is there a way to search string more than 255 chars....

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Search a sting in word doc with more the 255 chars

    InStr doesn't have a limit.

    What are you using that does have a 255 character limit?

  5. #5
    Registered User
    Join Date
    12-14-2012
    Location
    Hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Search a sting in word doc with more than 255 chars

    actually im using this code

    with Selection.Find
    .Forward = True
    .ClearFormatting
    .Replacement.ClearFormatting
    .MatchCase = True
    .MatchWholeWord = True
    .Text = Sheet1.Cells(i,2) 'value of i is increasing based on for loop
    .Replacement.Text = Sheet1.Cells(i,3)
    .Execute Replace:=wdReplaceAll
    end with

    so here if the length of Sheet1.Cells(i,2) is greater than 255 chars, it s giving error.

    So what i tried to do is split the value of Sheet(i,2) into 200 chars each, store 1st 200 in Array1(1), next 200 in Array1(2) and so on. and den comparing the values.... but in this case i cannot use .MatchWholeWord as it will always be false.
    Last edited by shankha_29; 12-14-2012 at 03:39 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1