?
Solved

Problem to copy file

Posted on 2016-07-15
7
Medium Priority
?
58 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

777 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