Elusive "Operation is not allowed in this context" Error
I keep getting an error 3219, "Operation is not allowed in this context." in my error log that originates from the function below. Everywhere I look online, the only references to this error are for ADO, but there are no ADO objects acted on in the function. I also have no luck when I try to replicate the error (it only shows up about once every 200 or so runs). I'm pretty sure that it isn't originating in any of the called functions, because they have their own error handlers. Any ideas? Can Word throw this error for some reason?
Public Function CreateNotReins() As Boolean
Dim sToOpen As String, sDeceased As String, sDate As String, sPolicy As String
Dim sFace As String, sCeded As String
On Error GoTo ErrorHand
bOutputGo = False
sDeceased = Trim$(.txtFirstName.Text) & " " & Trim$(.txtLastName.Text)
sDate = .txtDOD.Text
If sDate = "NA" Then
sDate = "Not Available"
sPolicy = .txtPolicyNum.Text
sFace = Format(.txtFace.Text, "$ #,###")
sCeded = "$ 0"
sToOpen = gsPath & "\DeathClaim.tpl"
If oWord Is Nothing Then
Set oWord = New Word.Application
Set oTemplate = oWord.Documents.Open(sToOpen)
.Bookmarks("Name").Range.Text = sDeceased
.Bookmarks("Date").Range.Text = sDate
.Bookmarks("Number").Range.Text = sPolicy
.Bookmarks("Face").Range.Text = sFace
.Bookmarks("Ceded").Range.Text = sCeded
.Bookmarks("NotReins").Range.Text = "Policy is not reinsured."
If bOutputGo = True Then
If PostProcess = True Then
CreateNotReins = True
If Err.Number <> 0 Then
sError = "Error number " & CStr(Err.Number) & "," & vbCrLf & Err.Description & "," & vbCrLf & _
"has occured in the CreateNotReins procedure."
Call ErrorLogger(Err.Number, Err.Description, "CreateNotReins", "sPolicy = " & sPolicy)
Call MsgBox(sError, vbCritical + vbOKOnly, "Critical Error")
Last edited by Comintern; November 9th, 2005 at 03:54 PM.