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