Hello!
I'm having a problem trying to close a word document from my access form with a button.
Basically my form takes all the data together from a form that is typed in and converts it into a paragraph format by a report that is exported into word where it can all be copied and pasted into the correct location. The users may forget that the Word Document is still open as they continue to process other data and when they click the button it'll error and close down access, losing all data.
I need the button to close that specific word document before it exports the new one so it can be overwritten without error. As for another kind of approach I've also tried setting errors to false so it just wouldn't close and erase everything if they happened to forget and try again after they do close it, but the error would still show up.
The runtime error is "3202" by the way if you needed to know.
This is the basic coding I got for the button right now without the failed codes.
Code:
Private Sub Command358_Click()
DoCmd.OutputTo acOutputReport, "Summary New", acFormatRTF, "U:\Administration\DESCRIPTION FORMS\Vehicle Summary.rtf", False
Dim LWordDoc As String
Dim oApp As Object
'Path to the word document
LWordDoc = "U:\Administration\DESCRIPTION FORMS\Vehicle Summary.rtf"
If Dir(LWordDoc) = "" Then
MsgBox "Document not found."
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
Thank you for your help!