Sharepoint Copy

Takes2ToTango

Board Regular
Joined
May 23, 2023
Messages
69
Office Version
  1. 365
Platform
  1. Windows
Hi,

Is there a way to get VBA/Excel to close any active copies of a sharepoint file?

My scenario is that a laptop will have a sharepoint copy of the excel file open. However, every 30 mins I want my master copy to open, close sharepoint, update all queries and then reopen the sharepoint.

Is this possible?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I don't have a sharepoint environment available and my experience with sharepoint with Excel is very limited.
So if the problem concerns the sharepoint environment, I'm the wrong person to help.

If the question mainly concerns the processing of workbooks, then I can try to help.


My apologies for any quirks, English is not my native language. "So I blame Google translate for all my goofs." :devilish:
 
Upvote 0
I don't know if this is of any use, but here is an outline of how to identify, close and reopen workbooks.

VBA Code:
Sub TS_WorkbookClosing()
Dim wbMaster As Workbook, wbi As Workbook
Dim SharePointFiles As New Collection, SharePointFile As Variant
Dim PartOfSharePointPath As String
PartOfSharePointPath = "somethin to here"               ' Put something here that is common to closed sharepoint file paths.
'Set wbMaster = Workbooks.Open("Full path and filename")' Open master workbook

For Each wbi In Workbooks                               ' Go through all open workbooks
    Debug.Print wbi.FullName                            ' print path&name
    
    If InStr(LCase(wbi.FullName), LCase(PartOfSharePointPath)) Then   ' close those workbooks which path or filename contains the string PartOfSharePointPath.
        SharePointFiles.Add wbi.FullName                ' Save Workbook path & name to collection
        wbi.Close SaveChanges:=False                    ' Close Workbook
    End If
    
Next

Application.Wait (Now + TimeValue("0:00:10"))           ' Waiting 10 seconds

For Each SharePointFile In SharePointFiles
    Workbooks.Open SharePointFile                       ' Opening previously closed workbooks
Next SharePointFile

End Sub

My apologies for any quirks, English is not my native language. "So I blame Google translate for all my goofs." :devilish:
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top