Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem to copy file

Posted on 2016-07-15
7
Medium Priority
?
59 Views
Last Modified: 2016-07-17
Hi,
I get
5c.pngdue 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
0
Comment
Question by:HuaMinChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 750 total points
ID: 41711859
Have you defined and instantiated the FileSystemObject object? It would be a good idea to name such as object with a different name from the class name:
Dim fso  as  New FileSystemObject

'...
fso.CopyFile Source, Dest
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 41711861
Sorry missed using a snippet box:
Dim fso  as  New FileSystemObject 

'...
fso.CopyFile Source, Dest

Open in new window

0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41711867
I still get error due to these
        Dim fso  As New FileSystemObject
        fso.CopyFile Source, Dest
        

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 53

Assisted Solution

by:Ryan Chong
Ryan Chong earned 750 total points
ID: 41711875
>>Dim fso  As New FileSystemObject
try check in References to see if there's any missing libraries?

alternatively, try this instead:
Dim fso As Object
fso = CreateObject("Scripting.FileSystemObject")
'...

Open in new window

0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 41711906
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.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41716214
I get
5f.pngdue 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.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 41716216
Please leave my last reply in above
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question