Tom Crowfoot
asked on
Manipulate RTF doc from Access
Dear Experts
I am trying to join up some VBA from Access & from Word ... basically I want to be able to open an RTF doc from Access, run a macro on it and then close it down
The word part works in the rtf doc all fine but I can't seem to get the code to open up the rtf doc & haven't looked at the saving the rtf doc yet. this is the code I have so far - I keep getting a compile error "User-defined type not defined"
Can anybody help?
I am trying to join up some VBA from Access & from Word ... basically I want to be able to open an RTF doc from Access, run a macro on it and then close it down
The word part works in the rtf doc all fine but I can't seem to get the code to open up the rtf doc & haven't looked at the saving the rtf doc yet. this is the code I have so far - I keep getting a compile error "User-defined type not defined"
Can anybody help?
Private Sub Command3_Click()
'open up RTF doc bit
Dim objWord As Word.Application
Dim docWord As Word.Document
Set objWord = CreateObject("Word.Application")
Set docWord = objWord.Documents.Add("C:\Users\xxxxx\Desktop\CiP-Client Interviews 1.rtf", False)
objWord.Visible = True
'manipulate RTF doc bit
With ActiveDocument
Selection.WholeStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Bold = True
With Selection.Find
.Text = "(||)(*)(\>\>)"
.Replacement.Text = "\2"
.Forward = True
.Wrap = wdFindAsk
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
' Save & close bit to go here
End With
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome!
/gustav
/gustav
ASKER