嗨,我对宏还很陌生,事实上,下面是我的 Frankenstein 代码,除了一个小问题外,它运行良好。我不希望用户在另存为窗口中使用取消按钮或 x 按钮,就像我的宏下面列出的第二个宏一样。我希望我的宏保持不变,但要添加代码以防止用户取消或退出另存为窗口。
Sub Auto_Open()
Dim Workbook_Name As Variant
MsgBox "Save to R drive prior to working", vbInformation + vbOKOnly, "Hello Ops Team"
If Dir("Z:\Provider Ops", vbDirectory) = "" Then
MsgBox "You are not connected to the R drive"
Exit Sub
End If
If ThisWorkbook.Name = "Triaging for Vendors.xlsm" Then Exit Sub
Workbook_Name = Application.GetSaveAsFilename("Z:Prov Ops\Triaging for Vendors")
If Workbook_Name <> False Then
ActiveWorkbook.SaveAs _
Filename:=Workbook_Name & ".xlsx", _
FileFormat:=51
End If
End Sub
_______________________________________________________________
Sub PreventCancel()
Dim fPth As Object
Set fPth = Application.FileDialog(msoFileDialogSaveAs)
Dim result As Variant
With fPth
.InitialFileName = CTAPath
.InitialFileName = CTAName & "_CAP DATA"
.Title = "Save with your CTA file"
.InitialView = msoFileDialogViewList
.FilterIndex = 2
Do
result = .Show
Loop While result <> True
.Execute
End With
end sub