|
-
Apr 12th, 2006, 06:46 AM
#1
Thread Starter
Lively Member
the replace function in word
Hi guys,
just wondering if i could create a macro which replaced a word with another word, which were stored in a macro. For example when the user types in Hello it checks the databse and then replaces it by another word lets say Bye.
Caz
-
Apr 12th, 2006, 11:52 AM
#2
Re: the replace function in word
It is possible to do that. For example you can achieve the same thing by using another document. You create a new document with a table with 2 column one for find string and another for replace string. Using VBA code search the first column string in your document and replace it with the 2nd column.
This is just an idea. if you need more help on that please reply.
Regards,
-
Apr 12th, 2006, 02:31 PM
#3
Thread Starter
Lively Member
Re: the replace function in word
yeh that sounds excellent, how would i refernce it to the table in the other word document?
would the other document have to be open?>
thanks for the help.
caz
-
Apr 12th, 2006, 02:37 PM
#4
Lively Member
Re: the replace function in word
This might sound a little simple, but can you not achieve your objective using Word's built in find and replace feature or, for replacement as you type, autocorrect feature?
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
Apr 12th, 2006, 02:52 PM
#5
Thread Starter
Lively Member
Re: the replace function in word
well not really cos there will be quite a few entries to change so i would keep on having to use the find and replace function, i think.
And in the end i would like it (if possible) to be at real time, so once you enter a word the program checks the database and then replaces it.
caz
-
Apr 12th, 2006, 03:04 PM
#6
Re: the replace function in word
Have a look at post #4 here on how to parse a textstream
The effort here was to change HTML tags, but the same approach can be used for your requirement, basically saving the list of find and replace values in a text file.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Apr 12th, 2006, 03:04 PM
#7
-
Apr 12th, 2006, 04:57 PM
#8
Thread Starter
Lively Member
Re: the replace function in word
cheers guys I am looking threw them.
I have kinda found a way just expanding on a previous example I had, but I cant get it working. COuld you please look at the code and see if you can spot anyhting. cheers
VB Code:
Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
Dim Word As String
Dim Prts() As String
Dim NewWord As String
If KeyCode = vbKeySpace Then
Prts = Split(Text2.Text, " ")
Word = Prts(UBound(Prts) - 1)
Do While Not MyRecordSet.EOF
If LCase(Word) = MyRecordSet.Fields("SearchText") Then
Text1.Text = Replace(Text2.Text, Word, MyRecordSet.Fields("ReplacementText"))
Text1.SelStart = Len(Text2.Text)
Exit Sub
End If
MyRecordSet.MoveNext
Loop
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|