通过VBA重新共享工作簿时禁止自动SaveAs覆盖提示
Private Sub Workbook_Open()
Dim WBname As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
WBname = ActiveWorkbook.Name
'Turn off SHARING
If Workbooks(WBname).MultiUserEditing Then
Workbooks(WBname).ExclusiveAccess
End If
'Conditional formatting code that needs to be run when un-shared
Sheets("Current Period").Select
Columns("C:C").Select
Selection.FormatConditions.Delete
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions _
(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
lngLast = Range("C" & Rows.Count).End(xlUp).Row
Range("C" & lngLast).Select
'Save Workbook/Re-Share
ThisWorkbook.SaveAs ThisWorkbook.FullName, AccessMode:=xlShared
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub()
我认为这会抑制所有提示,但是当文件重新共享时,我会收到SaveAs Overwrite提示,如果我手动操作,通常会得到这个提示。感谢。