Microsoft Forms: Could not load some objects because they are not available on this machine

RobertN

New Member
Joined
Jan 10, 2020
Messages
19
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am running this scrip (find and replace in multiple workbooks) in Excel 2019 (Office 365) and get the "Microsoft Forms: Could not load some objects because they are not available on this machine" error, but only the first time I run it. after subsequent runs against the same files, it doesn't pop up again. In Debug mode, the message is popping up after " Set wb = Workbooks.Open(wFile)" executes. Everything seems to run fine after dismissing the message. How would I resolve or ignore this message? I need this to be able to run on any machine running Office 365. Thanks so much for your help!

VBA Code:
Sub Unprotect_worksheets()
    Dim wb As Workbook, ws As Worksheet
    Dim wPath As String, wQuan As Long, n As Long
    Dim fso As Object, folder As Object, subfolder As Object, wFile As Object
   
    Application.DisplayAlerts = False
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Application.StatusBar = False
   
    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        If .Show <> -1 Then Exit Sub
        wPath = .SelectedItems(1)
    End With


    Set fso = CreateObject("scripting.filesystemobject")
    Set folder = fso.getfolder(wPath)
   
    wQuan = folder.Files.Count
    n = 1
    For Each wFile In folder.Files
        Application.StatusBar = "Processing folder : " & folder & ". File : " & n & " of : " & wQuan
        If Right(wFile, 4) Like "*xls*" Then
            [COLOR=rgb(184, 49, 47)][B][U]Set wb = Workbooks.Open(wFile)[/U][/B][/COLOR]
            For Each ws In wb.Sheets
                ws.Unprotect "DocAdmin1"
            Next
            wb.Close True
        End If
        n = n + 1
    Next
   
    For Each subfolder In folder.subfolders
        wQuan = subfolder.Files.Count
        n = 1
        For Each wFile In subfolder.Files
            Application.StatusBar = "Processing folder : " & subfolder & ". File : " & n & " of : " & wQuan
            If Right(wFile, 4) Like "*xls*" Then
                Set wb = Workbooks.Open(wFile)
                For Each ws In wb.Sheets
                ws.Unprotect "DocAdmin1"
                Next
                wb.Close True
            End If
            n = n + 1
        Next
    Next
   
    Application.ScreenUpdating = True
    Application.StatusBar = False
   
    Set fso = Nothing: Set folder = Nothing: Set wb = Nothing
   
    MsgBox "All sheets in all Task Spreadsheets are now unprotected"
End Sub
 
Last edited by a moderator:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Watch MrExcel Video

Forum statistics

Threads
1,129,587
Messages
5,637,252
Members
416,963
Latest member
samfuge

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
Top