Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 - folder copy dependant on username

Posted on 2004-09-20
5
Medium Priority
?
179 Views
Last Modified: 2010-05-02
I'm writing a small program to help facilitate migration of users as well as learn more about VB6.  I would like to copy the favorites folder from a Windows 200 Pro user account and copy it into another folder named after the user.
What I have so far is copying the all of the folders under the username instead of just the Favorites folder.  

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "c:\documents and settings\" & strUser & "\Favorites\", "c:\Migration\" & strUser

The folders structure "C:\Migration\User" is already in place from an earlier event.

Any guidance would be appreciated.
0
Comment
Question by:acksis
[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
  • 2
5 Comments
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12112821
Try using
 "c:\documents and settings\" & strUser & "Favorites"    <---- no '\' at the end...
0
 

Author Comment

by:acksis
ID: 12113276
>>Try using
>> "c:\documents and settings\" & strUser & "Favorites"    <---- no '\' at the end...

No good - same results
0
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 400 total points
ID: 12113997
That's interesting; your code (without the extra '\') worked for me...

I changed it to the following, to meet my network spec
    strUser = InputBox("Enter username")
    strDSFolder = "d:\documents and settings"
    strFolderToCopy = "favorites"
   
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFolder strDSFolder & "\" & strUser & "\" & strFolderToCopy, "c:\Migration\" & strUser

and it worked fine.

Very odd...

You are an Administrator of your machine?
0
 

Author Comment

by:acksis
ID: 12115251
I tried to modify my code to match yours and got the same results but when I actually did a copy and paste it worked.  I'm not really sure what the problem was.  I would suspect a typo but the code posted in my question is also copied and pasted.

Regardless, your solution worked - thanks for the help.
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12121094
No problem.  If you ever find out why yours didn't work, let me know...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

705 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