Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cant get Word97 Replace All to work
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00181347
Message ID:
00181647
Views:
10
Bret,

Text inside shapes is not in the document as you have found. You have to use the Shapes collection to find the one you are looking for. I'm doing a very similar thing and here's a method I'm using:
lparameter plShape, pcItem, pcText

this.SetStatus( "Filling in " + pcItem )

local llFound, loShape, loRange, loRetVal

llFound = .f.
loRetVal = .null.

if ( plShape )
   * look for it in the shapes
   with this.moContract
      for each loShape in .Shapes
         if ( loShape.TextFrame.HasText = -1 )
            loRange = loShape.TextFrame.TextRange
            with loRange.Find
               .Text = pcItem
               .Replacement.Text = alltrim( pcText )
               .Forward = .t.
               .Execute( ,,,,,,,,,, wdReplaceOne )
               llFound = .Found
            endwith
         endif
         if ( llFound )
            * skip doing rest of shapes
            if ( empty( pcText ) )
               * going to do formattedtext inserts
               loRetVal = loRange
               loRetVal.Collapse( wdCollapseEnd )
            endif
            exit
         endif
      endfor
   endwith
else

   * look for it in the document body
   loRange = this.moContract.Content
   with loRange.Find
      .Text = pcItem
      .Replacement.Text = alltrim( pcText )
      .Forward = .t.
      .Execute( ,,,,,,,,,, wdReplaceOne )
      llFound = .Found
   endwith
   if ( empty( pcText ) )
      * going to do formattedtext inserts
      loRange.Collapse( wdCollapseEnd )
      loRetVal = loRange
   endif

endif

if ( ! llFound and ! this.mlWarned  )
   Confirm( "Can not find the item:" + pcItem, MB_OK + MB_ICONEXCLAMATION )
   ErrorLog( "Missing:" + pcItem )
   this.mlWarned = .t.
endif

return loRetVal
>I found out the problem, my Word entries from VFP are to shape boxes:
>
>loWord.ActiveDocument.Shapes("Text Box 6").Select
>
>That is where I enter my data. Now when I ask Word to replace all the operation goes ok outside of VFP when I am in word 97 editing the document. Inside VFP I have to select the box and then do the replace for it to work. I am wondering if this is a bug or what. I can select my boxes in order to replace the text, but it will be a pain.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform