Thanks Tom. Your change in addition to changing the ReadOnly parameter
to True got me past that error. However, the program exits the subroutine at
the next set statement. Am I approaching the correctly? Iam a programmer ;
but, I don't speak VB. The text I am trying to replace is in the body of the
document, not the header. I would like the Replace command to search the
entire document for the string provided.
--
Paul
"Tom van Stiphout" wrote:
> On Tue, 14 Oct 2008 10:38:08 -0700, PBI
> <(E-Mail Removed)> wrote:
>
> Change that to:
> Dim MSWordDoc As Word.Document
> or you may get a Type Mismatch.
>
> Also, be sure to run Task Manager (alt_ctrl_del > Task Manager >
> Processes and be sure that MsWord is not running. It could be running
> invisibly (especially if you set that argument to False).
>
> -Tom.
> Microsoft Access MVP
>
>
> > I am attempting to insert data in a Word document from an Access
> >database using VB6 code. The code compiles without errors; however, when
> >executed the locked for editing error pops up. I know that the document is
> >not in use and the error message is triggered by:
> >
> >Set MSWordDoc = wd.Documents.Open("H:\Test2.doc", , False, , , , , , , , ,
> >False)
> >
> >Sub code follows:
> >
> >Public Sub EdDoc(strField1 As String)
> >Const Find = "[OCCASION]"
> >Dim MSWordDoc As Document
> >Dim wd As New Word.Application
> >Dim rng As Range
> >Dim hf As HeaderFooter
> >Dim s As Section
> >Set MSWordDoc = wd.Documents.Open("H:\Test2.doc", , False, , , , , , , , ,
> >False)
> >Set rng = hf.Range
> > With rng.Find
> > .Text = Find
> > .Replacement.Text = strField1
> > .Execute Replace:=wdReplaceAll
> > End With
> >DoCmd.Save ("H:\Notice.doc")
> >DoCmd.Close
> >wd.Quit
> >End Sub
> >
> >Please help.
>
|