tonestauk
06-25-2003, 04:23 AM
I have a macro code that i want to run. At the moment it is setup to run from a specific directory that is in the code. I need to create a form that the macro will be able to pick up from a drivelist and filelist as to which folder to run the macro code on. Could any one help me with this please..??
tonestauk
06-25-2003, 04:32 AM
I attached the code that i have so far.
I have a macro code that i want to run. At the moment it is setup to run from a specific directory that is in the code. I need to create a form that the macro will be able to pick up from a drivelist and filelist as to which folder to run the macro code on. Could any one help me with this please..??
'having a Drivelistbox and a Dirlistbox on ur form
Dim sCurrentPath As String 'will always hold the current path
Private Sub Dir1_Change()
sCurrentPath = Dir1.Path
MsgBox sCurrentPath
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
tonestauk
06-25-2003, 04:48 AM
That didnt do anything. As you can see from the code attached, l have created the drive list and directory list. What l need is; when l select a directory and click the command button, for it to run a XLS macro that l have on all XLS files in the selected directory. At the moment, the code is setup so that it will open run the macro on XL:S in a specifed directory, l need it to be able to select a directory from the form then run it on that. Thanks, hope this is more clear, sorry.!!
That didnt do anything. As you can see from the code attached, l have created the drive list and directory list. What l need is; when l select a directory and click the command button, for it to run a XLS macro that l have on all XLS files in the selected directory. At the moment, the code is setup so that it will open run the macro on XL:S in a specifed directory, l need it to be able to select a directory from the form then run it on that. Thanks, hope this is more clear, sorry.!!
Private Sub Dir1_Change()
File1.path = Dir1.path
End Sub
Private Sub Drive1_Change()
Dir1.path = Drive1.Drive
End Sub
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To File1.ListCount - 1
'put whatever u want to do with the files here
MsgBox File1.path & File1.List(i) & " is being processed"
Next i
End Sub
and don't forget to set the Pattern property of the FileListBox to *.xls