SherryO
01-31-2006, 11:30 AM
I have the following code which is only part of a whole routine. What I'm tyring to do is prompt the user to enter a name for a new directory that I am going to create and then copy two subdirectories into. I have included only one subdirectory since they are just about identical. My problem is that when I try to CopyFolder into the newly created directory, I get the compile error that a constant expression is required. Please help, it's driving me bonkers.
Thanks!
Sub total()
Call NetDirectory
Call CopyFileNetworkWO
End Sub
Sub NetDirectory()
Dim HistoryDir As String
'****Asks the user to input the Dir name, then creates Dir
Load UserForm3
UserForm3.Show
HistoryDir = UserForm3.TextBox1.Value
MkDir "K:\History\2006\" & HistoryDir
End Sub
Sub CopyFileNetworkWO()
Dim HistoryDir As String
HistoryDir = UserForm3.TextBox1.Value
'****This is copying the files from C:\WithoutCost to J:\WithoutCost
Const DirFromM As String = "c:\withoutcost"
Const DirToM As String = "K:\History\2006\" & HistoryDir & "\" 'This is the problem
Dim fso As FileSystemObject
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FilesystemObject")
oFSO.CopyFolder DirFromM, DirToM
End Sub
Thanks!
Sub total()
Call NetDirectory
Call CopyFileNetworkWO
End Sub
Sub NetDirectory()
Dim HistoryDir As String
'****Asks the user to input the Dir name, then creates Dir
Load UserForm3
UserForm3.Show
HistoryDir = UserForm3.TextBox1.Value
MkDir "K:\History\2006\" & HistoryDir
End Sub
Sub CopyFileNetworkWO()
Dim HistoryDir As String
HistoryDir = UserForm3.TextBox1.Value
'****This is copying the files from C:\WithoutCost to J:\WithoutCost
Const DirFromM As String = "c:\withoutcost"
Const DirToM As String = "K:\History\2006\" & HistoryDir & "\" 'This is the problem
Dim fso As FileSystemObject
Dim oFSO As Object
Set oFSO = CreateObject("Scripting.FilesystemObject")
oFSO.CopyFolder DirFromM, DirToM
End Sub