Using Find & Replace in Word 2007 via DDE.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 18
Accepted Solution

Using Find & Replace in Word 2007 via DDE.

Hi,

I am trying to get SAS to open a Word 2007 document via DDE and find some text, with a view to replacing that text.

This used to be easy before VBA, now the example find command is this:

With Selection.Find

    .Forward = True

    .ClearFormatting

    .MatchWholeWord = True

    .MatchCase = False

    .Wrap = wdFindContinue

    .Execute FindText:="Microsoft"

End With

I have tried to wrap this into a DDE command.

   data _null_;

     file ddecmds;

     put '[With Selection.Find'

         ' .Forward = True'

         ' .ClearFormatting'

         ' .MatchWholeWord = True'

         ' .MatchCase = False'

         ' .Wrap = wdFindContinue'

         ' .Execute FindText:="Microsoft"'

         'End With ]';

   run;

However it gets mangled into this, which is a syntax error:

Private Sub TmpDDE()

Dim With_

Dim FindText

With_ WordBasic.Call "Selection.Find",.Forward = WordBasic.Call "True_.ClearFormatting",.MatchWholeWord = WordBasic.Call("True_.MatchCase") = WordBasic.Call("False_.Wrap") = WordBasic.Call "wdFindContinue.Execute_", FindText : = "Microsoft" End With_

End Sub

Does anyone know how to call Find from SAS?,


Accepted Solutions
Solution
‎07-08-2013 08:18 AM
Respected Advisor
Posts: 3,799

Re: Using Find & Replace in Word 2007 via DDE.

Posted in reply to MichaelPearce

All Replies
Solution
‎07-08-2013 08:18 AM
Respected Advisor
Posts: 3,799

Re: Using Find & Replace in Word 2007 via DDE.

Posted in reply to MichaelPearce
Occasional Contributor
Posts: 18

Re: Using Find & Replace in Word 2007 via DDE.

Posted in reply to data_null__

Hi data_null,

Excellent, EditReplace.

Thank you.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 555 views
  • 0 likes
  • 2 in conversation