Consulting

Results 1 to 3 of 3

Thread: run Time error '76 -looking for files within Sharepoint

  1. #1
    VBAX Newbie
    Joined
    May 2012
    Posts
    3
    Location

    run Time error '76 -looking for files within Sharepoint

    Can someone please advise on the below and why I'm getting a run-time error? i'm trying to open up folders/files within Sharepoint and copy/past data into a summary sheet. Any advice is appreciated.

    Sub OH()
    Dim objFSO As Object
    Dim objFolder As Object
    Dim objSubFolder As Object
    Dim objFile As Object
    Dim MyFolder As String
    Dim wkbOpen As Workbook
    Dim wkb As Workbook
    Dim wks As Worksheet
    Dim CalcMode As Long
    With Application
    CalcMode = .Calculation
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    'Change the path accordingly
    MyFolder = ttp://communities.bv.com/sites/WFP/Shared%20Documents/2012%202Q%20Forecast"

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(MyFolder) 'getting error message here
    Set wkb = ActiveWorkbook
    Set wks = ActiveSheet

    For Each objSubFolder In objFolder.SubFolders
    For Each objFile In objSubFolder.Files
    Set wkbOpen = Workbooks.Open(objFile.Path)
    Sheets("Input Staff").Select
    Range("C1").Select
    Selection.Copy
    Windows("OH Sharepoint macro.xlsm").Activate
    Sheets("Summary").Select
    If Range("B2") = "" Then
    Range("B2").Select
    ActiveSheet.Paste
    End If
    Range("B2").End(xlDown).Select
    ActiveCell.Offset(1, 0).Select
    ActiveSheet.Paste

    wkbOpen.Close savechanges:=True
    Next objFile
    Next objSubFolder

    With Application
    .Calculation = CalcMode
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    MsgBox "Completed...", vbInformation

    End Sub

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    Should this line not be?
    [VBA]MyFolder = "http://communities.bv.com/sites/WFP/Shared%20Documents/2012%202Q%20Forecast"[/VBA]

  3. #3
    VBAX Newbie
    Joined
    May 2012
    Posts
    3
    Location
    Yes.

Posting Permissions

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