Hello forum members and guests!
I need your help in solving an issue I get when trying to assign a worksheet to a worker based on a combobox option (worker's name). When the value of combobox "Assign" is "Now", the worksheet should be saved to a folder named for the worker who is getting the file. The value of combobox "Worker" should provide the name of the worker so that the file is saved to his folder with his name in the file's name.
Here's the code I'm trying to use to accomplish the task but it isn't working... I get the error: "Object doesn't support this property or method".
Private Sub cmdSubmit2_Click()
Dim myFile As String, myFolder As String
Select Case Userform2.cboAssign.Value
Case "Not Yet"
If Userform2.cboAssign.Value = "Not Yet" Then
End If
Case "Now"
If Userform2.cboAssign.Value = "Now" Then
Application.DisplayAlerts = False
myFolder = "\\XEN01\shared\test\" & WorksheetFunction(UserForm2.cboWorker.Value) & "\"
myFile = myFolder & "YT- " & WorksheetFunction(UserForm2.cboWorker.Value) & " " & Format(Date, "mm-dd-yyyy") & ".xlsm"
If Not IsFileExists(myFile) Then
ActiveWorkbook.SaveAs "\\XEN01\shared\test\" & WorksheetFunction(UserForm2.cboWorker.Value) & "\" & "YT- " &_ WorksheetFunction(UserForm2.cboWorker.Value) & " " & Format(Date, "mm-dd-yyyy") & ".xlsm", FileFormat:=52
End If
Application.DisplayAlerts = True
End Select
End Sub
The function "IsFileExists" is declared and defined inside a worksheet module. I've been working on this for a while and I can't seem to find the solution to the problem... I may be missing something trivial but can't put my finger on it at the moment. Please let me know if anyone can come up with something.
Many thanks!!!
Bookmarks