Link to home
Start Free TrialLog in
Avatar of shieldsco
shieldscoFlag for United States of America

asked on

Copy files from a Folder to a SharePoint Folder using Access vba

I trying to use the below code to copy files from my local drive using Access VBA however receiving an error Invalid Outside Procedure in the FromPath

Option Compare Database
Option Explicit
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
 FromPath = "C:\Ryan\MultipleFilesFrom" '<< Change
 ToPath = "https://collaboration.net/sites/Shared%20Documents/"
 If Right(FromPath, 1) = "\" Then
 FromPath = Left(FromPath, Len(FromPath) - 1)
 End If
 If Right(ToPath, 1) = "/" Then
 ToPath = Left(ToPath, Len(ToPath) - 1)
 End If
 Set FSO = CreateObject("scripting.filesystemobject")
 If FSO.FolderExists(FromPath) = False Then
 MsgBox FromPath & " doesn't exist"
 Exit Sub
 End If
 FSO.CopyFolder Source:=FromPath, Destination:=ToPath
 MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
 End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kimputer
Kimputer

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial