Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem to copy file

Hi,
I get
User generated imagedue to this line
        FileSystemObject.CopyFile Source, Dest

while Source is having value
\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\CHINA\AsiaPacific_Budget_HO_2016-May.xlsm

Dest is
\\hkgmoss\sites\a4\IT\Projects\ExcelTool\BudgetExcelTool\CHINA\AsiaPacific_Budget_HO_CHINA_2016-Jun.xlsm
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Sorry missed using a snippet box:
Dim fso  as  New FileSystemObject 

'...
fso.CopyFile Source, Dest

Open in new window

Avatar of Peter Chan

ASKER

I still get error due to these
        Dim fso  As New FileSystemObject
        fso.CopyFile Source, Dest
        

Open in new window

SOLUTION
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
If the error is

Compile error:
User-defined type not defined

then Ryan Chong's advice should work

Whenever you want to ask about an error, please tell us what the error message is.
I get
User generated imagedue to last line below
        Source = Replace(Replace(Source, "\", "/"), "//", "http://"): Dest = Replace(Replace(Dest, "\", "/"), "//", "http://")
        
        Dim fso As Object
        'Set fso = VBA.CreateObject("Scripting.FileSystemObject")
        Set fso = CreateObject("Scripting.FileSystemObject")
        'Dim fso  As New FileSystemObject
        fso.CopyFile Source, Dest

Open in new window

and Source is having value

http://hkgmoss/sites/a4/IT/Projects/ExcelTool/BudgetExcelTool/CHINA/AsiaPacific_Budget_HO_2016-May.xlsm

Open in new window

while Dest is
http://hkgmoss/sites/a4/IT/Projects/ExcelTool/BudgetExcelTool/CHINA/AsiaPacific_Budget_HO_CHINA_2016-Jun.xlsm

Open in new window

I still get the same problem even if I did not do replace on 1st line in above.
Please leave my last reply in above