ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   I need to change this code to copy All files the "customdoc" folde (https://www.excelbanter.com/excel-programming/348237-i-need-change-code-copy-all-files-customdoc-folde.html)

macrowriter

I need to change this code to copy All files the "customdoc" folde
 
Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "CHARM.PCD" file from "CUSTOMDOC FOLDER"
' to "TEST FOLDER".
FileCopy sSourcePath, sTargetPath

If Err 0 Then MsgBox Err.Description
End Sub


Bob Phillips[_6_]

I need to change this code to copy All files the "customdoc" folde
 
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\", True

Set oFSO = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"macrowriter" wrote in message
...
Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "CHARM.PCD" file from "CUSTOMDOC FOLDER"
' to "TEST FOLDER".
FileCopy sSourcePath, sTargetPath

If Err 0 Then MsgBox Err.Description
End Sub




macrowriter

I need to change this code to copy All files the "customdoc" f
 
I just tried this and I got a compile error:syntax error in the following line:

oFSO.CopyFolder ""C:\PNTTEMPL\CustomDoc\*",
""C:\PNTTEMPL\CustomDoc\TEST\", True


"Bob Phillips" wrote:

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\", True

Set oFSO = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"macrowriter" wrote in message
...
Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "CHARM.PCD" file from "CUSTOMDOC FOLDER"
' to "TEST FOLDER".
FileCopy sSourcePath, sTargetPath

If Err 0 Then MsgBox Err.Description
End Sub





Martin Fishlock[_3_]

I need to change this code to copy All files the "customdoc" f
 
Try removing the one of double double quotes on both lines.

HTHs.



"macrowriter" wrote:

I just tried this and I got a compile error:syntax error in the following line:

oFSO.CopyFolder ""C:\PNTTEMPL\CustomDoc\*",
""C:\PNTTEMPL\CustomDoc\TEST\", True


"Bob Phillips" wrote:

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\", True

Set oFSO = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"macrowriter" wrote in message
...
Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "CHARM.PCD" file from "CUSTOMDOC FOLDER"
' to "TEST FOLDER".
FileCopy sSourcePath, sTargetPath

If Err 0 Then MsgBox Err.Description
End Sub





macrowriter

I need to change this code to copy All files the "customdoc" f
 
I tried this:
oFSO.CopyFolder "C:\PNTTEMPL\CustomDoc\*",
"C:\PNTTEMPL\CustomDoc\TEST\", True
and got Compile Error: Expected: line number or label or statement or end of
statement.

then i tried making it one line like this:
oFSO.CopyFolder "C:\PNTTEMPL\CustomDoc\*", "C:\PNTTEMPL\CustomDoc\TEST\", True
And got run-time error '5' Invalid procedure call or argument

"Martin Fishlock" wrote:

Try removing the one of double double quotes on both lines.

HTHs.



"macrowriter" wrote:

I just tried this and I got a compile error:syntax error in the following line:

oFSO.CopyFolder ""C:\PNTTEMPL\CustomDoc\*",
""C:\PNTTEMPL\CustomDoc\TEST\", True


"Bob Phillips" wrote:

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\", True

Set oFSO = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"macrowriter" wrote in message
...
Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "CHARM.PCD" file from "CUSTOMDOC FOLDER"
' to "TEST FOLDER".
FileCopy sSourcePath, sTargetPath

If Err 0 Then MsgBox Err.Description
End Sub





Bob Phillips[_6_]

I need to change this code to copy All files the "customdoc" f
 
Martin,

Your working har5d for this :-))

Try this
oFSO.CopyFolder "C:\PNTTEMPL\CustomDoc\*", _
"C:\PNTTEMPL\CustomDoc\TEST\", True


--

HTH

RP
(remove nothere from the email address if mailing direct)


"macrowriter" wrote in message
...
I tried this:
oFSO.CopyFolder "C:\PNTTEMPL\CustomDoc\*",
"C:\PNTTEMPL\CustomDoc\TEST\", True
and got Compile Error: Expected: line number or label or statement or end

of
statement.

then i tried making it one line like this:
oFSO.CopyFolder "C:\PNTTEMPL\CustomDoc\*", "C:\PNTTEMPL\CustomDoc\TEST\",

True
And got run-time error '5' Invalid procedure call or argument

"Martin Fishlock" wrote:

Try removing the one of double double quotes on both lines.

HTHs.



"macrowriter" wrote:

I just tried this and I got a compile error:syntax error in the

following line:

oFSO.CopyFolder ""C:\PNTTEMPL\CustomDoc\*",
""C:\PNTTEMPL\CustomDoc\TEST\", True


"Bob Phillips" wrote:

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\", True

Set oFSO = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"macrowriter" wrote in

message
...
Sub FileCopyExample()
Dim sSourcePath As String
Dim sTargetPath As String

' Change these paths to your Source and Target paths.
sSourcePath = "C:\PNTTEMPL\CustomDoc\CHARM.PCD"
sTargetPath = "C:\PNTTEMPL\CustomDoc\TEST\CHARM.PCD"
On Error Resume Next

' Copy the file "CHARM.PCD" file from "CUSTOMDOC FOLDER"
' to "TEST FOLDER".
FileCopy sSourcePath, sTargetPath

If Err 0 Then MsgBox Err.Description
End Sub








All times are GMT +1. The time now is 08:24 PM.

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