Results 1 to 2 of 2

Open multiple excel files on sharepoint using VBA

Threaded View

  1. #1
    Registered User
    Join Date
    03-26-2013
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    1

    Open multiple excel files on sharepoint using VBA

    Hi,
    I'm new to this forum and hope for some help. Thanks in advance to the cool experts.

    I would like to open a file dialog where the user can select multiple Excel files which then will be opened and values extracted into a consolidation Excel workbook. Have tried to change my code in a fileserver environment to a SharePoint equivvalent - but it doesn't work.

    Sub TestSharepointFileOpen()
        'Declare a variable as a FileDialog object.
        Dim fd As FileDialog
        'Declare a variable to contain the path of each selected item. Even though the path is aString,
        'the variable must be a Variant because For Each...Next routines only work with Variants and Objects.
        Dim vrtSelectedItem As Variant
        Dim wbBusinessCase As Workbook
    
    
        Application.ScreenUpdating = False
        Application.DisplayAlerts = False
        Application.EnableEvents = False 
    
    
        'Create a FileDialog object as a File Picker dialog box.
        Set fd = Application.FileDialog(msoFileDialogFilePicker)
        fd.InitialFileName = "\\sites\projects\"
    
        'Use a With...End With block to reference the FileDialog object.
        With fd
    
            'Allow the user to select multiple files.
            .AllowMultiSelect = True
    
            'Use the Show method to display the File Picker dialog box and return the user's action.
            'If the user presses the button...
            If .Show = -1 Then
                'Step through each string in the FileDialogSelectedItems collection.
                For Each vrtSelectedItem In .SelectedItems
                    Set wbBusinessCase = Workbooks.Open(vrtSelectedItem, ReadOnly:=True) 'actual command to open each file
                    wbBusinessCase.Close SaveChanges:=False 'close each file after it has been copied from
                Next
            'If the user presses Cancel...
            Else
            End If
        End With
    
      
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        Application.EnableEvents = True 
    
    End Sub
    Last edited by arlu1201; 02-04-2014 at 01:37 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1