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

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

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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