Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to open all files in SharePoint Library

I need to write a macro to open all the files in a libray on a SharePoint. I found the code below which looks very straightforward but I get the error "User-defined type not defined" for each of the Dim statements. It appears that I need to add some references, but can anyone tell me what references I need to select to make this code work?

Public Sub ListFiles()
Dim folder As folder
Dim f As File
Dim fs As New FileSystemObject
Dim RowCtr As Integer
RowCtr = 1
Set folder = fs.GetFolder("\\SP\Path\MorePath\DocumentLibrary\F older")
For Each f In folder.Files
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
Next f
End Sub

As an alternative is there a method that does not require adding references? I have also seen suggestions that mapping the sharepoint to a drive letter would be helpful but this is not an optimum solution as many people will eventually use this tool and it is not likely that they can all map the same drive letter.

Any suggestions or tips would be much appreciated.

Win7/Excel 2010
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Macro to open all files in SharePoint Library

Here is the solution that we have developed:

Sub Execute_Files()
Dim objFSO As Object, objFolder As Object, objFile As Object
Dim Path As String

' Define paths to folders that contain files to execute

path = "http://blah/blah/blah/blah/"
Application.DisplayAlerts = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Path)

' Loop through the Files in the folder and execute the macro in the
file, then close the file

For Each objFile In objFolder.Files
Workbooks.Open Filename:=Path & objFile.Name
Application.Run ("'" & objFile.Name & "'!macro_name")
Workbooks(objFile.Name).Close savechanges:=False
Next
Application.DisplayAlerts = True
End Sub

On Tue, 19 Jun 2012 01:04:33 -0700 (PDT), John
wrote:

I need to write a macro to open all the files in a libray on a SharePoint.


John Keith

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why cant I get the path to the sharepoint library???????? nancy drew Excel Programming 7 April 28th 11 02:02 AM
Wht can't I open Excel files from Sharepoint any more? HH Excel Discussion (Misc queries) 1 January 17th 10 08:49 PM
Open Sharepoint site & Determine the number of files and their nam Chilidog Excel Programming 1 June 12th 09 01:18 AM
Macro to count files on sharepoint Tommy W Excel Programming 0 January 13th 08 08:49 PM
Can a Macro open workbooks on a SharePoint Site? Randy Excel Discussion (Misc queries) 0 August 29th 06 07:21 PM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"