Solved

Problem to copy file

Posted on 2016-07-15
7
47 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
  • 3
  • 3
7 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 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 10

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 49

Assisted Solution

by:Ryan Chong
Ryan Chong earned 250 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 10

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 10

Author Comment

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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now