Syntax Error using FileCopy

  • Thread starter Thread starter Dkline
  • Start date Start date
D

Dkline

I'm getting a "Compile Error" "Syntax Error" on the last line of the
subroutine:
CopySourceFiles(strDailyPath,strDailyName,strlocalpath)

As you can see the last argument is not being acccepted as it is all lower
case rather than the mixed case in the Dim.

For some reason it doesn't like the third argument. Basic purpose of this
code is to copy seven files from various network locations into a local
subdirectory

Below is the entire code:

Option Explicit
Dim wbFilesDailyUpdate As Workbook
Dim wsFiles As Worksheet
Dim strLocalPath As String
Dim strGetFilePath As String
Dim strGetFile As String
Dim strDailyPath As String
Dim strAndesaPath As String
Dim strTransactionsPath As String
Dim strDailyName As String
Dim strSingleName As String
Dim strJointName As String
Dim strAnnuityName As String
Dim strTablesName As String
Dim strTransactionsName As String
Dim strDCTableName As String
Dim strGetPathFile As String
Dim strCopyToPathFile As String

Sub GetCurrentFiles()
Set wbFilesDailyUpdate = ThisWorkbook
Set wsFiles = wbFilesDailyUpdate.Worksheets("Files")
strLocalPath = wsFiles.Range("LocalPath").Value
'Get Daily Balance File
strDailyPath = wsFiles.Range("DailyPath").Value
strDailyName = wsFiles.Range("DailyName").Value
CopySourceFiles(strDailyPath,strDailyName,strlocalpath)
End Sub

Function CopySourceFiles(GetPath, GetFile, ToPath)
strCopyToPathFile = ToPath & "\" & GetFile
strGetPathFile = GetPath & "\" & GetFile
FileCopy strGetPathFile, strCopyToPathFile
End Function
 
Parentheses should be put around parameters to function
calls only when a result is being returned. Try

CopySourceFiles strDailyPath,strDailyName,strlocalpath

Hope This Helps
Gerald Stanley MCSD
 
<Picky>

Not quite. You can use parentheses with Subs if you want. However, when you
do, you must use the Call keyword:

Call CopySourceFiles (strDailyPath,strDailyName,strlocalpath)

or

CopySourceFiles strDailyPath,strDailyName,strlocalpath

</Picky>
 
Thanks. Problem solved.

Gerald Stanley said:
Parentheses should be put around parameters to function
calls only when a result is being returned. Try

CopySourceFiles strDailyPath,strDailyName,strlocalpath

Hope This Helps
Gerald Stanley MCSD
 
<Picky><Picky>

And you can use parameters if you want to force the parameter to be passed
"by value" instead of "by reference":

n = 11
blat n
msgbox n ' 22
blat (n)
msgbox n ' 22!

sub blat (prm as integer)
prm = 2 * prm
end sub

Don't have Access here to check, but I believe the above is correct.

TC
 
Back
Top