Opening SharePoint Workbooks

Slicemahn

Board Regular
Joined
Jun 10, 2004
Messages
120
Hello Everyone,

I having difficulty in getting this code to execute smoothly. This is the "Update" portion of the code, where the excel report is opened from a SharePoint location, checked out, and then the data refresh performed including any Pivot Tables/Caches. I want the opened or updated Excel file to open in another window and the code executed to do as I stated. What I am finding is interruptions with the blanking out of the current workbook when going to the desired workbook. At times, the updated workbook will not show and the code doesn't wait for all the refreshes to be done.

VBA Code:
Sub Collect_Actions()
Dim strFile$
Dim ReportRow As Long, ReportCount As Long
Dim wb As Object


With ThisWorkbook.Worksheets("Sheet1")
     ReportCount = .[a2].CurrentRegion.Rows.Count
End With

ReportRow = 2


Do While ReportRow <= ReportCount

Application.ScreenUpdating = False
Application.StatusBar = "Reviewing report " & ReportRow & " of " & ReportCount
    
' Set conditions for Update, Retire, and Renew

Select Case Cells(ReportRow, 11)

Case "Renew"
Application.StatusBar = Cells(ReportRow, 2) & "is currently undergoing " & Cells(ReportRow, 4) & "ing process..."
            If Cells(ReportRow, 5) <> "Inactive" Then
                 Application.Wait (Now + TimeValue("00:00:02"))
            Application.StatusBar = "Report " & Cells(ReportRow, 2) & " is already active."
            End If
            'Update log with Date, Time, Report, Error: Renew Task Not Completed, URL, Description:  Report is already active.
            Cells(ReportRow, 5) = "Active"
            Cells(ReportRow, 12) = "Request Complete"
            Cells(ReportRow, 13) = Format(Now, "mm/dd/yyyy hh:mm AM/PM")
Application.StatusBar = Cells(ReportRow, 2) & " has been renewed."

Case "Retire"
Application.StatusBar = Cells(ReportRow, 2) & "is currently undergoing the " & Cells(ReportRow, 4) & "process..."
            If Cells(ReportRow, 5) <> "Active" Then
            Application.Wait (Now + TimeValue("00:00:02"))
            Application.StatusBar = "Report " & Cells(ReportRow, 2) & " is an inactive report."
            End If
            'Write to Error Log Date, Time, Report, Error: Task Not Completed, URL, Description: This report is already retired.
            Cells(ReportRow, 5) = "Inactive"
            Cells(ReportRow, 12) = "Request Complete"
            Cells(ReportRow, 13) = Format(Now, "mm/dd/yyyy hh:mm AM/PM")
Application.StatusBar = Cells(ReportRow, 2) & " has been retired."


Case "Update"
Application.StatusBar = Cells(ReportRow, 2) & " is currently undergoing" & Cells(ReportRow, 4) & "ing process ..."
            If Cells(ReportRow, 5) <> "Active" Then
            Application.Wait (Now + TimeValue("00:00:02"))
            Application.StatusBar = "Report " & Cells(ReportRow, 2) & " is not an active report."
            ' Write this in error log
            End If
    ' Begin data refresh process
    
    Set wb = Workbooks.Open(ReportRow, 4)
    Workbooks.CheckOut Cells(ReportRow, 4)
    'Debug.Print "Opened"
    wb.RefreshAll
    'Debug.Print "Refresh started"
    wb.Application.CalculateUntilAsyncQueriesDone
    'Debug.Print "Ensured refresh completed with calculate"
    Application.DisplayAlerts = False 'Prevent message for saving as macro free workbook
    wb.CheckIn
    Application.DisplayAlerts = True
    'Debug.Print "Checked In"
     Cells(ReportRow, 12) = "Request Complete"
     Cells(ReportRow, 13) = Format(Now, "mm/dd/yyyy hh:mm AM/PM")
Application.StatusBar = Cells(ReportRow, 2) & " has been refresh."


End Select

ReportRow = ReportRow + 1

Loop

Application.ScreenUpdating = True

End Sub


Report_Snip.xlsb
ABCDEFGHIJKLMNOPQRSTUVWX
1LocationReport NameBusiness UnitLinkStatusPriorityCommentsSupportTeam LeadRefresh CycleChoice 1ResultTime StampDate AppliedOlinkElinkAlinkUpdatedUpdated ByAudienceIDCountPathChecked
2North Buildingabc.xlsxMarketinghttps://sharepoint.com/Marketing/abc.xlsxActiveLowStaffTom FieldingWeeklyRenewRequest Complete########4/21/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/21/2022 11:45 AMTom Fielding145321CLASSIFIEDYes
3Central BuildingEmployee_Asset.xlsxAdminhttps://sharepoint.com/Admin/Employee_Asset.xlsxActiveMedDeptSuzanne DurrantWeekly4/24/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/24/2022 9:30 AMMichelle Fennings194521CLASSIFIEDYes
4DMZEnd Point Mappings.xlsxIThttps://sharepoint.com/IT/End Point Mappings.xlsxActiveHighDeptHenry NguyenBi-Weekly4/11/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/11/2022 3:30 PMLazar Popovic124491CLASSIFIEDYes
5West QuadStudent Residence.xlsxResidencehttps://sharepoint.com/Residence/Student Residence.xlsxActiveLowStaffBob HamiltonWeekly4/21/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/21/2022 11:45 AMRiston Comich145321CLASSIFIEDYes
6East QuadCustodial_Projects 2022.xlsxFacilitieshttps://sharepoint.com/Facilities/Custodial_Projects 2022.xlsxActiveMedDeptHector RodriguezWeekly4/24/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/24/2022 9:30 AMDarlene Love194521CLASSIFIEDYes
7North BuildingSys_Org_diag.xlsxIThttps://sharepoint.com/IT/Sys_Org_diag.xlsxActiveHighDeptHenry NguyenBi-Weekly4/11/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/11/2022 3:30 PMMark Kisel124491CLASSIFIEDYes
8South PointStudent_RAC_Membership.xlsxMarketinghttps://sharepoint.com/Marketing/Student_RAC_Membership.xlsxActiveLowStaffTom FieldingWeekly4/21/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/21/2022 11:45 AMAaron Ladner145321CLASSIFIEDYes
9West QuadEmployee_Asset.xlsxAdminhttps://sharepoint.com/Admin/Employee_Asset.xlsxActiveMedDeptSuzanne DurrantWeekly4/24/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/24/2022 9:30 AMChris Continental194521CLASSIFIEDYes
10East QuadCash Reconciliation Report.xlsxFacilitieshttps://sharepoint.com/Facilities/Cash Reconciliation Report.xlsxActiveHighDeptHector RodriguezBi-Weekly4/11/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/11/2022 3:30 PMEnzo Ramoni124491CLASSIFIEDYes
11West QuadE2E Cost Report.xlsxMarketinghttps://sharepoint.com/Marketing/E2E Cost Report.xlsxActiveLowStaffTom FieldingWeekly4/21/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/21/2022 11:45 AMHailey Read145321CLASSIFIEDYes
12LibraryResource Allocations-Volumes by Floor.xlsxStudent Resourceshttps://sharepoint.com/Student Resources/Resource Allocations-Volumes by Floor.xlsxInactiveMedDeptChristmas MartinWeeklyRenew4/24/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/24/2022 9:30 AMCarlton Spence194521CLASSIFIEDYes
13RAC FacilitiesGym Memberships 2022.xlsxRecreation Facilityhttps://sharepoint.com/Recreation Facility/Gym Memberships 2022.xlsxActiveLowStaffHannah WorthingtonWeekly4/21/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/21/2022 11:45 AMRobert Westall145321CLASSIFIEDYes
14RAC FacilitiesGym Asset Tracker.xlsxRecreation Facilityhttps://sharepoint.com/Recreation Facility/Gym Asset Tracker.xlsxInactiveMedDeptHannah WorthingtonWeekly4/24/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/24/2022 9:30 AMHarold Snell194521CLASSIFIEDYes
15East QuadSupplies List.xlsxFacilitieshttps://sharepoint.com/Facilities/Supplies List.xlsxActiveHighDeptHector RodriguezBi-Weekly4/11/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/11/2022 3:30 PMColin George124491CLASSIFIEDYes
16West QuadHousing RSVP Fall 2023.xlsxResidencehttps://sharepoint.com/Residence/Housing RSVP Fall 2023.xlsxActiveLowStaffBob HamiltonWeekly4/21/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/21/2022 11:45 AMYaroslav Popovic145321CLASSIFIEDYes
17North BuildingSCOA Budgets.xlsxAccountinghttps://sharepoint.com/Accounting/SCOA Budgets.xlsxActiveMedDeptSteven FischerallWeeklyRetire4/24/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/24/2022 9:30 AMSuzanne Durrant194521CLASSIFIEDYes
18Central BuildingCost Benefit Analyses_Spring 2022.xlsxIThttps://sharepoint.com/IT/Cost Benefit Analyses_Spring 2022.xlsxActiveHighDeptHenry NguyenBi-Weekly4/11/2022CLASSIFIEDCLASSIFIEDCLASSIFIED04/11/2022 3:30 PMSamantha Crozier124491CLASSIFIEDYes
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=HYPERLINK("https://sharepoint.com/"&C2&"/"&B2)
Cells with Data Validation
CellAllowCriteria
K2:K18ListUpdate, Retire, Renew
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
The RefreshAll method is asynchonous. From Help: "Objects that have the BackgroundQuery property set to True are refreshed in the background."
So you must either set backgroundquery of all queries to false, or write your own code using the refresh method of each query and pivot cache. The Refresh methods have a BackgroundQuery argument.
 
Upvote 0
The RefreshAll method is asynchonous. From Help: "Objects that have the BackgroundQuery property set to True are refreshed in the background."
So you must either set backgroundquery of all queries to false, or write your own code using the refresh method of each query and pivot cache. The Refresh methods have a BackgroundQuery argument.
Thank you for this response. I am not clear on what you mean here. Are you saying the other files that are to be opened should have the BackgroundQuery property set to False? How do I go back and forth between the two? Use of ThisWorkbook and create another instance of Excel for the other workbook?
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,850
Members
449,051
Latest member
excelquestion515

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