ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I get run time error '5' when I run this code. any sugestions? (https://www.excelbanter.com/excel-programming/348247-i-get-run-time-error-5-when-i-run-code-any-sugestions.html)

macrowriter

I get run time error '5' when I run this code. any sugestions?
 
Sub FileCopyExample()
Dim oFSO As Object
Dim sSourcePath As String
Dim sTargetPath As String

Set oFSO = CreateObject("Scripting.FileSystemObject")

oFSO.CopyFolder "C:\PNTTEMPL\CustomDoc\*", "C:\PNTTEMPL\CustomDoc\TEST\"
Set oFSO = Nothing

End Sub

Leith Ross[_386_]

I get run time error '5' when I run this code. any sugestions?
 

Hello Macrowriter,

You need to set a reference to the Scripting Runtime library in
project.

1. Open the VBA editor uising ALT + F11
2. Press ALT + T to drop down the Tools menu.
3. Press R to bring up the References dialog.
4. Search for the listing Microsoft Scripting Runtime
5. Click the checkbox on the left. A check mark indicates it is
selected.
6. Press Enter to close the dialog.
7. Press ALT + S to save the change to your project.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=493961



All times are GMT +1. The time now is 02:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com