Below is my code, which works perfectly...
The only other thing i would like to add is
To the active document. Please can u help me with how to implement this into my code.
Thanks
Code:
Private Sub WorksReport_Click()
Dim LWordDoc As String
Dim oApp As Object
Dim MWordDoc As String
MWordDoc = "Z:\WorksReport\V" & Me.VisitNumber & ".docx"
'Path to the word document
LWordDoc = "Z:\WorksReport\V" & Me.VisitNumber & ".docx"
Debug.Print LWordDoc
If Dir(LWordDoc) = "" Then
LWordDoc = "Z:\WorksReport\VXXXXX.docx"
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:=LWordDoc
ActiveDocument.SaveAs FileName:=MWordDoc
Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True
'Open the Document
oApp.Documents.Open FileName:=LWordDoc
End If
End Sub
The only other thing i would like to add is
Code:
.FormFields("VisitNumber").Result = Me!VisitNumber
To the active document. Please can u help me with how to implement this into my code.
Thanks
Last edited: