Mark121
01-23-2008, 02:08 AM
Hi All
I am using the folowing code to copy folder across to a backup directory but doesn’t seem to like ‘%username%\’ to capture the current user. Any ideas why or what is should be replaced with?
On Error Resume Next
Dim objShell
Dim objFolder
Dim SourceFolder
Dim TargetFolder
SourceFolder ="c:\documents and settings\%username%\my documents"
TargetFolder = "H:\Backup"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TargetFolder)
objFolder.CopyHere SourceFolder, 16
MsgBox ("Backup Completed Succesfully")
Thanks
Mark
I am using the folowing code to copy folder across to a backup directory but doesn’t seem to like ‘%username%\’ to capture the current user. Any ideas why or what is should be replaced with?
On Error Resume Next
Dim objShell
Dim objFolder
Dim SourceFolder
Dim TargetFolder
SourceFolder ="c:\documents and settings\%username%\my documents"
TargetFolder = "H:\Backup"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(TargetFolder)
objFolder.CopyHere SourceFolder, 16
MsgBox ("Backup Completed Succesfully")
Thanks
Mark