いつもありがとうございます
教えてください Accessは2010を使っています
下記のコードでモジュールの書換えをしています
ところが ←←←←← のところで
エラー『この操作を 完了することができません。 コードを中断し、再度実行してください』が出たり
出なかったりします
何が問題で再現性のないエラーが出るのでしょうか
よろしくお願いいたします
Dim myMDL As Module
Dim myArray As Variant
Dim buf As Variant
Dim i As Integer
Dim j As Integer
myArray = Array( _
"M:M_モジュール1 :AAA:Dim i As Integer:Dim iii As Integer", _
"F:Form_フォーム1:BBB:Dim x As Integer:Dim xxx As Integer" _
)
For i = 0 To UBound(myArray)
buf = Split(myArray(i), ":")
If Trim(buf(0)) = "F" Then DoCmd.OpenForm Replace(Trim(buf(1)), "Form_", ""), acDesign
DoCmd.OpenModule Trim(buf(1))
Set myMDL = Application.Modules(Trim(buf(1)))
With myMDL
SLine = .ProcStartLine(Trim(buf(2)), vbext_pk_Proc)
CLine = .ProcCountLines(Trim(buf(2)), vbext_pk_Proc)
For j = SLine To SLine + CLine - 1
If InStr(.Lines(j, 1), Trim(buf(3))) > 0 And Left(Trim(.Lines(j, 1)), 1) <> "'" And InStr(.Lines(j - 1, 1), Trim(buf(4))) = 0 Then
.InsertLines j, Trim(buf(4)): j = j + 1
End If
Next j
If Trim(buf(0)) = "F" Then
DoCmd.Close acForm, Split(Trim(buf(1)), "_")(1), acSaveYes
Else
DoCmd.Save acModule, myMDL.NAME ←←←←←
End If
End With
Set myMDL = Nothing
Next i