How do I get the strings from ms office find and replace?

I would like to write a program that monitors ms office's find and replace utility, and every time the replace or replace all button is pressed I want the two strings stored in a file. I have no idea how to do this or where to start. Any advice or suggestions? Thanks.

Edit:
I read this link http://support.microsoft.com/kb/196776 about office automation with c++ but I am still a bit confused.
Last edited on
I would use a VBA Macro to make a component object model connection to your program. I'd have to fiddle around to figure out exactly how to do it, but that's how I'd approach it.
I don't currently have office, so I'd have a hard time giving specifics, but you can attach macros to specific office commands. You may be able to have a macro run at the initiation of the find and replace that hooks input.
I was able to record a macro and it looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Sub mymacro()
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "The dog is red"
        .Replacement.Text = "The dog is blue"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    With Selection
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseStart
        Else
            .Collapse Direction:=wdCollapseEnd
        End If
        .Find.Execute Replace:=wdReplaceOne
        If .Find.Forward = True Then
            .Collapse Direction:=wdCollapseEnd
        Else
            .Collapse Direction:=wdCollapseStart
        End If
        .Find.Execute
    End With
End Sub


I don't understand how to incorporate this into my program. I have never used VB and have taken a C class and am currently taking a C++ class.
I see that i can #include "C:\Program Files (x86)\Microsoft Office\Office12\msword.olb".
I am not sure how to use the VB and C++ together.
Including it is like typing it into your code at that point. Obviously that's not C++, so including will do you no good. You will have to come up with a parsing system to go through and deal with the file. Since it's in a human-readable string format, it will be easier to read but much harder to code an interpreter for.
Last edited on
Topic archived. No new replies allowed.