Importing from sharepoint using VBA almost there (I think)

praktikant

New Member
Joined
Dec 9, 2014
Messages
9
Hi all,

I've been working on a excel workbook, where I want to import a workbook from a specific excel file, that is located in a sharepointfolder, into another excel file (named Import.xlsm).

I'm able to import the workbook, if source-file is on my C-drive and .xls format.

Private Sub CommandButton1_Click()

Dim directory As String, fileName As String, sheet As Worksheet, total As Integer

Application.ScreenUpdating = False
Application.DisplayAlerts = False

directory = "C:\Users\John\Desktop\NewFolder\"
fileName = Dir(directory & "*.xl??")

Do While fileName <> ""

Workbook.Open (directory & fileName)

For Each sheet In Workbooks(fileName).Worksheets
total = Workbooks("import.xlsm").Worksheets.Count
Workbooks(fileName).Worksheets(sheet.Name).Copy _
after:=Workbooks("import.xlsm").Worksheets(total)

Next sheet

Workbooks(fileName).Close

fileName = Dir()

Loop

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub


I've inserted the code that works and marked the path red. My problem is at when I try to use the path from sharepoint: http://infonet/Workspace/FU/Shares%20documents/Maps/GanttCharts.xlsm

It doesn't work when it's from the sharepoint (I've tried to change the format from .xslm to xls)

Can anyone help me?

The objective is that the user of Import.xlsm, can click on the macro button, and import the Ganttcharts-sheets from sharepoint without getting access to the source-file.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

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