F
Fly Girl
I'm trying to capture events in an instance of Word from my MS Access
app. What I have so far will open the file, but the DocumentBeforeSave
event doesn't fire.
In a class module I have:
________________________________________________________________________________
Public WithEvents appWord As Word.Application
Public WithEvents docWord As Word.Document
Private Sub appWord_DocumentBeforeSave(ByVal Doc As Word.Document,
SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "This record is locked. You cannot save this file.", _
vbInformation + vbOKOnly, "Locked Record"
Cancel = True
End Sub
________________________________________________________________________________
In my code module I'm doing the following (non-relevant portions
omitted):
_______________________________________________________________________________
Public Function OpenFile()
On Error GoTo Err_OpenFile
Dim frm As Form
Dim bolWordOpen As Boolean
Dim clsWord As New clsMSWord
Dim strFile As String
Set frm = Screen.ActiveForm
If frm![EventsSub].Form!FileType = "doc" Then
Set clsWord.appWord = CreateObject("Word.Application")
clsWord.appWord.Visible = True
strFile = frm![EventsSub].Form.txtLinkFilePath
' Check to see if the record is locked. Open the file
appropriately.
If frm![EventsSub].Form.Locked Then
' Open the document
Set clsWord.docWord =
clsWord.appWord.Documents.Open(strFile, , , _
False, , , , , , , ,
True)
End If
Else
' Otherwise let Access OLE open the attached file
frm![EventsSub].Form.oleLinked.Action = acOLEActivate
End If
Exit Function
Err_OpenFile:
Call adcRunTimeErr(Err.Number, Err.Description, "OpenFile")
End Function
_______________________________________________________________________________
Any suggestions? Thanks!
app. What I have so far will open the file, but the DocumentBeforeSave
event doesn't fire.
In a class module I have:
________________________________________________________________________________
Public WithEvents appWord As Word.Application
Public WithEvents docWord As Word.Document
Private Sub appWord_DocumentBeforeSave(ByVal Doc As Word.Document,
SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "This record is locked. You cannot save this file.", _
vbInformation + vbOKOnly, "Locked Record"
Cancel = True
End Sub
________________________________________________________________________________
In my code module I'm doing the following (non-relevant portions
omitted):
_______________________________________________________________________________
Public Function OpenFile()
On Error GoTo Err_OpenFile
Dim frm As Form
Dim bolWordOpen As Boolean
Dim clsWord As New clsMSWord
Dim strFile As String
Set frm = Screen.ActiveForm
If frm![EventsSub].Form!FileType = "doc" Then
Set clsWord.appWord = CreateObject("Word.Application")
clsWord.appWord.Visible = True
strFile = frm![EventsSub].Form.txtLinkFilePath
' Check to see if the record is locked. Open the file
appropriately.
If frm![EventsSub].Form.Locked Then
' Open the document
Set clsWord.docWord =
clsWord.appWord.Documents.Open(strFile, , , _
False, , , , , , , ,
True)
End If
Else
' Otherwise let Access OLE open the attached file
frm![EventsSub].Form.oleLinked.Action = acOLEActivate
End If
Exit Function
Err_OpenFile:
Call adcRunTimeErr(Err.Number, Err.Description, "OpenFile")
End Function
_______________________________________________________________________________
Any suggestions? Thanks!