想要在顶部检查此Exit Sub不会给我带来其他问题。它似乎工作,添加到我的代码的其余部分供参考。
“建立文件扩展名”类型的所有内容都已达到日期/到此为止。不确定是否只显示以下代码段就足以回答这个问题。
If invalid > 0 Then mbResult = MsgBox("Something's missing. Please check and try again. There are " & invalid & " incomplete fields.", _
vbOKOnly)
Select Case mbResult
Case vbOK
Exit Sub
End Select
'Establish File Extension type
With Destwb
If Sourcewb.Name = .Name Then
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End If
End With
FileExtStr = ".xlsm"
FileFormatNum = 52
'Save the new workbook and close it
TempFilePath = ("www.mysharepoint.com") & "\"
TempFileName = Range("A1").Text
'Confirm Submission
mbResult = MsgBox("This submission cannot be undone. Would you like to continue?", _
vbYesNo)
Select Case mbResult
Case vbNo
Exit Sub
End Select
'Build .SaveAs file Name based on variables established previously
With Destwb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Application.DisplayAlerts = True
ThisWorkbook.Activate
'Display successful submission message
MsgBox ("Thank you, your assessment has been successfully submitted.")
ActiveSheet.Protect
End Sub
答案 0 :(得分:1)
您可以更改这些行:
If invalid > 0 Then mbResult = MsgBox("Something's missing. Please check and try again. There are " & invalid & " incomplete fields.", _
vbOKOnly)
Select Case mbResult
Case vbOK
Exit Sub
End Selec
到此:
If invalid > 0 Then
MsgBox "Something's missing. Please check and try again. There are " & _
invalid & " incomplete fields.", vbOKOnly
Exit Sub
End If