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.
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.
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.