1
刪除使用VBA coding.I在用戶窗體子程序它存在於用戶窗體functionif試圖驗證碼刪除由VBA編碼
Sub DeleteProcedureCode(_
ByVal DeleteFromModuleName As String, ByVal ProcedureName As String)
' deletes ProcedureName from DeleteFromModuleName in wb
Dim VBCM As CodeModule, ProcStartLine As Long, ProcLineCount As Long
On Error Resume Next
Set VBCM = ActiveWorkbook.VBProject.VBComponents(DeleteFromModuleName).CodeModule
If Not VBCM Is Nothing Then
' determine if the procedure exist in the codemodule
ProcStartLine = 0
ProcStartLine = VBCM.ProcStartLine(ProcedureName, vbext_pk_Proc)
If ProcStartLine > 0 Then ' prosedyren finnes, slett den
ProcLineCount = VBCM.ProcCountLines(ProcedureName, vbext_pk_Proc)
VBCM.DeleteLines ProcStartLine, ProcLineCount
End If
Set VBCM = Nothing
End If
On Error GoTo 0
End Sub
但是,這將引發一個錯誤說用戶定義沒有定義
爲什麼你需要刪除一個子?你不能簡單地忽略它嗎? –