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?

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

Open in new window

correlateAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
Either:

Dim objWord As Object
Dim docWord As Object

or (better) go to Tools, References and add a reference to Word.

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
correlateAuthor Commented:
Brilliant - thank you very much - I forgot to add the reference to word!
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.