0
Hi I'm very new to macros in fact below is my Frankenstein code which works great except for one little issue. I do not want the users to use the cancel button or the x button when in the save as window just like the second macro listed below my macro. I want my macro to stay the same with the exception of adding the code for preventing users from canceling or x'ing out of the save as window.
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
2Don't. Instead, allow the user to cancel gracefully and deal suitably with the condition ... An un-cancelable modal dialog will bite you at some time. (E.g., what if there is no drive with write access and/or enough drive space? Or if Z: gets disconnected between your test in the first line and the saveas?) – Hagen von Eitzen – 2019-06-15T18:45:26.907
Currently the users are saving the file/s back to the intranet causing rework for everyone. So what I need is what I have posted here under Sub Auto_Open() and some how add the feature from Sub PreventCancel(). I'm extremely new to macros and any help would be appreciated.. – JamRivera – 2019-06-18T23:16:53.067