Below is vba code to open a file based on a selection in a drop-down box.
The files that are being opened have passwords to open. So when a value is
selected in the drop-down box, excel goes out and opens the file, and then
asks for the password. This is exactly what I want it to do; however, there
is one small problem. If the incorrect password is entered or if the user
hits cancel, the debug option pops up. As I do not want end user to see
this, can I construct some type of if statement that eliminates the debug
error from popping up? Also, one more important piece of info...there is a
unique open password applied to each file.
Private Sub Labor_Template_Change()
If Labor_Template.Value = "" Then
MsgBox "Please select a Function", vbInformation
End If
If Labor_Template.Value <> "" Then
Workbooks.Open
Filename:="H:\GO\FINANCE\BUDGETS\2006_Plan\Assumptions\Assmptn_LABOR\" &
"AL_" & Labor_Template.Value & ".xls"
End If
End Sub
Bookmarks