cannot find project or library-Copying files from one folder to another

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,599
Office Version
  1. 2021
Platform
  1. Windows
I have the following code to copy all the workbooks (.Xlsm files) from one folder "C:\Parts & SVC Sales" to another folder
"C:\My Documents"

It would be appreciated if someone could assist in resolving this


When running the macro error message comes up "cannot find project or library" and referes to the code below

Code:
 If Right(FromPath, 1) = "\" Then



Code:
 Dim FromPath As String
Dim ToPath As String

FromPath = "C:\Parts & SVC Sales"
ToPath = "C:\My Documents"



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
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Look under Tools>References... for anything marked as MISSING and uncheck it, but keep s note of the name before unchecking.
 
Upvote 0
Works ok on my PC (Windows 7).
I get the message From Path doesnt exist which is correct
 
Upvote 0
Thanks for the reply. Norie's suggestion has sorted out the problem
 
Upvote 0

Forum statistics

Threads
1,224,315
Messages
6,177,841
Members
452,809
Latest member
mar_luna

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