[英]vba Excel - How to Check if a SharePoint Website File is Open
I've searched the internet for the answer to this and keep running into issues getting it to work. 我在互联网上搜索了此问题的答案,并一直遇到使它无法正常工作的问题。
I need to check if a file at the below location is open/locked, and then have the code wait 15 seconds and then try again. 我需要检查以下位置的文件是否已打开/锁定,然后让代码等待15秒钟,然后重试。 Right now if someone else has the file open a dialog box opens asking if I want to open read only, which I don't want. 现在,如果其他人打开了文件,则会打开一个对话框,询问我是否要以只读方式打开文件,而我不想这样做。 I tried using Application.DisplayAlerts = False to get the message not to appear but that didn't seem to work. 我尝试使用Application.DisplayAlerts = False来使消息不出现,但似乎不起作用。 So I have two main issues: 所以我有两个主要问题:
Workbooks.Open filename:= _ " https://somecorporatewebsite/sites/TNKYWest/Engr/ASE%20Updates/Shared%20Documents/ASENW Updater.xlsx" Workbooks.Open文件名:= _“ https:// somecorporatewebsite / sites / TNKYWest / Engr / ASE%20Updates / Shared%20Documents / ASENW Updater.xlsx”
From MSDN site: https://msdn.microsoft.com/en-us/library/office/ff193284.aspx 从MSDN站点: https : //msdn.microsoft.com/en-us/library/office/ff193284.aspx
Sub UseCanCheckOut(docCheckOut As String)
Dim docCheckout
set docCheckout="File name to open"
' Determine if workbook can be checked out.
If Workbooks.CanCheckOut(Filename:=docCheckOut) = True Then
Workbooks.CheckOut (Filename:=docCheckOut)
Else
Found at the MSDN Website: https://msdn.microsoft.com/en-us/library/office/ff822851.aspx 在MSDN网站上找到: https : //msdn.microsoft.com/en-us/library/office/ff822851.aspx
Application.Wait(Now + TimeValue("0:00:10"))
Workbooks.CheckOut (Filename:=docCheckOut) 'Try to check the file out again.
End If
End Sub
This part is covered in the 这部分包含在
IF workbooks.cancheckout(filename:=docCheckout)=true then workbooks.checkout ' method in part 1. IF workbooks.cancheckout(filename:= docCheckout)= true然后在第1部分中使用workbooks.checkout'方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.