Automation Error

J

JonWayn

The code below is in xl VBA. I programatically open an Access database and
am attempting to insert a line of code in a specified module. I get the
error message 'Automation error. <vbcrlf> The RPC server is unavailable'
sometimes when either of the lines (below) followed by asterisks is
executed. Anyone here have any idea what causes this error?

Private Sub cmdInsert_Click()
Dim LineDef As LineParam, TestSpec As ProcSpecs
Dim ctl As Control
Dim InsertWhere$, CurrentProcedure$
Dim BreaksCount%

InsertWhere = IIf(optBefore, "before", "After")

If MsgBox("Are you sure you want to insert the text above " &
InsertWhere & _
" the selected line?", vbQuestion + vbYesNo + vbDefaultButton2, _
"Line Deletion Confirmation") = vbYes Then

LineDef = GetLineParam(lstBodyLines)
TestSpec = Specs(cboProcs.ListIndex + 1)
Set ctl = ActiveControl
txtEdLine.SetFocus
BreaksCount = txtEdLine.LineCount
ctl.SetFocus

If optBefore Then
mdl.InsertLines LineDef.Start, Nz(txtEdLine, vbCrLf)
'************************
Else
mdl.InsertLines LineDef.End + 1, Nz(txtEdLine, vbCrLf)
'***********************
End If

ListProcedureLines TestSpec.Start, TestSpec.EndLine + BreaksCount
End If
End Sub
 
Top