0
我試圖檢查下面的工作簿文件是否已經在代碼試圖運行時的「編輯模式」中打開。我試圖計劃何時會因爲其他人已經在文件中而出錯。我需要Workbook.Open
打開爲ReadOnly = False
,因爲如果沒有人在裏面,我需要能夠在更新後保存。如何在使用VBA打開Excel工作簿時繞過SharePoint「只讀」警報。
我遇到的問題是,即使DisplayAlerts = False
當Workbook.Open
行運行時,我也會看到一個屏幕提示,指出「文件已被鎖定以供(某些用戶)編輯。是否希望:查看讀取 - 僅複製或保存並編輯該文件的副本。「還有一個複選框顯示「當服務器文件可用時接收通知」。 DisplayAlerts = False
似乎無法取消SharePoint提示。任何想法爲什麼不會取消promt? 我想在代碼中試圖在編輯模式下打開的點,但不能,然後去If Activeworkbook.Readonly Then
行並退出子。現在它停止並等待SharePoint提示中的選擇。
Sub SendFCSpec()
MsgBox ("Please wait while your comments are sent to the database.")
ActiveSheet.Unprotect Password:="BAS1"
'Turn Screen Updating and Alerts off
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'Disable Macros on AutoOpen of the Excel Workbook
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Workbooks.Open Filename:="http://Sharepoint.com/QA/FC%20QA%20Workshop/Databases/Dec/FC%20Spec%20Database.xlsm", _
UpdateLinks:=3, ReadOnly:=False
If ActiveWorkbook.ReadOnly Then
ActiveWorkbook.Close
MsgBox "Another user has the database open. Unable to submit comments at this time."
Application.AutomationSecurity = msoAutomationSecurityLow
Exit Sub
End If
Application.AutomationSecurity = msoAutomationSecurityLow
ActiveWorkbook.Save
ActiveWorkbook.Close
ActiveSheet.Select
ActiveSheet.Protect Password:="BAS1", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowSorting:=True, AllowFiltering:=True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox ("Comments have been saved to the Database. Thanks")
End Sub
哇。我閱讀了Workbook.Open幫助指南,完全沒有看到Notify解釋的其餘部分。謝謝! – arooney88