CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    516

    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?
    Code:
    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
    
        With frmDeathClaim
            sDeceased = Trim$(.txtFirstName.Text) & " " & Trim$(.txtLastName.Text)
            sDate = .txtDOD.Text
            If sDate = "NA" Then
                sDate = "Not Available"
            End If
            sPolicy = .txtPolicyNum.Text
            sFace = Format(.txtFace.Text, "$ #,###")
            sCeded = "$ 0"
        End With
        
        sToOpen = gsPath & "\DeathClaim.tpl"
        
        If oWord Is Nothing Then
            Set oWord = New Word.Application
        End If
        
        Set oTemplate = oWord.Documents.Open(sToOpen)
        
        With oTemplate
            .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."
        End With
        
        frmOutputOpts.Show (vbModal)
        frmDeathClaim.Repaint
        
        If bOutputGo = True Then
            If PostProcess = True Then
                CreateNotReins = True
            End If
        End If
    
    ErrorHand:
        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)
            Err.Clear
            Call MsgBox(sError, vbCritical + vbOKOnly, "Critical Error")
        End If
    
    End Function
    Last edited by Comintern; November 9th, 2005 at 04:54 PM. Reason: Typo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured