Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Im opening (checking out) an Excel file from SharePoint and trying to apply
a test to see if there is another Excel file in SharePoint already open. If there is an Excel file open, I want a prompt to be displayed to a user. If there is currently no Excel file checked out, then the user can open the file without any problem. Heres the code I have so far: Option Explicit Sub UseCanCheckOut() Dim xlApp As Excel.Application Dim wb As Workbook Dim xlFile As String xlFile = "https://globalconsumer.w.net/sites/Shared%20Documents/test/" & ActiveWorkbook.Name If Workbooks.CanCheckOut(ActiveWorkbook.Path & "/" & ActiveWorkbook.Name) = True Then Workbooks.CheckOut (ActiveWorkbook.Path & "/" & ActiveWorkbook.Name) MsgBox "Is checked out to you." Else MsgBox "Cannot be checked out to you." End If 'Determine if workbook can be checked out. If Workbooks.CanCheckOut(xlFile) = True Then Workbooks.CheckOut xlFile Set xlApp = New Excel.Application xlApp.Visible = True Set wb = xlApp.Workbooks.Open(xlFile, , False) ' MsgBox wb.Name & " is checked out to you." ' Else ' MsgBox "You are unable to check out this document at this time." End If Call MyMacro End Sub Sub MyMacro() If IsFileOpen("https://globalconsumer.w.net/sites/Shared%20Documents/test/" & ActiveWorkbook.Name) Then ' Display a message stating the file in use. MsgBox "Another similar file is already in use!" End If End Sub Function IsFileOpen(filename As String) Dim filenum As Integer, errnum As Integer On Error Resume Next filenum = FreeFile() Open filename For Input Lock Read As #filenum Close filenum errnum = Err On Error GoTo 0 Select Case errnum Case 0 IsFileOpen = False Case 70 IsFileOpen = True End Select End Function I think it's going to be something like that. I'm certainly not an expert with SharePoint!! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to programmically upload Excel file to Sharepoint? | Excel Programming | |||
Open Sharepoint Hosted Excel File, in Excel, Using VBA | Excel Programming | |||
VBA Code to open an Excel file on a sharepoint site | Excel Programming | |||
Saving an XML file to a sharepoint location using VBA in excel | Excel Programming | |||
code to check file size everytime an Excel file is opened | Excel Programming |