Merge Excel Files Saved in SharePoint

JVRamoso02

New Member
Joined
Apr 29, 2016
Messages
4
Hi,

I have a macro in my local drive which allows me to merge multiple workbooks saved in a specific folder into one workbook. I need these files to be stored in SharePoint instead of local drive but when I try to change the path to a destination in SharePoint, the macro returns an error for "FileName = Dir(Path & "\*.xlsm", vbNormal)" and I cannot figure out how I can fix it. Could anyone please help me how I can rewrite the codes to make it work? Appreciate your help.



Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Option Explicit
 
Sub CallMacros()
     
    Dim Path            As String
    Dim FileName        As String
    Dim Wkb             As Workbook
    Dim Ws              As Worksheet
    Dim Ary             As Variant
     
    'merge workbooks into one
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Path = "https:\\*****group.sharepoint.com\teams\InnovationSupportAPACBCR\Shared Documents\TEST MACRO\Countries\" 'Change as needed
   [COLOR=#FF0000]FileName = Dir(Path & "\*.xlsm", vbNormal)[/COLOR]
    Do Until FileName = ""
        Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
        For Each Ws In Wkb.Worksheets
            Ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
        Next Ws
        Wkb.Close False
        FileName = Dir()
    Loop
    Application.EnableEvents = True
    Application.ScreenUpdating = True</code>
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,224,836
Messages
6,181,248
Members
453,026
Latest member
cknader

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