Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default down with the debug error

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\Assumpt ions\Assmptn_LABOR\" &
"AL_" & Labor_Template.Value & ".xls"
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default down with the debug error

H7^3,
This worked for me: ( It catches both the [Cancel] button and the wrong
password condition)

Sub Macro1()
On Error GoTo FileNotOpened
Workbooks.Open Filename:="C:\testfile.xls"
MsgBox "File Opened"
Exit Sub

FileNotOpened:
MsgBox "No Luck"
End Sub


Alex J

"hurlbut777" wrote in message
...
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\Assumpt ions\Assmptn_LABOR\" &
"AL_" & Labor_Template.Value & ".xls"
End If
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debug Error Ed Davis Excel Discussion (Misc queries) 7 June 16th 09 03:10 PM
Debug Error Ed Davis Excel Discussion (Misc queries) 0 June 16th 09 09:59 AM
Debug error 1004 Kasper Excel Discussion (Misc queries) 7 January 27th 09 02:21 PM
Debug Error Saxman Excel Discussion (Misc queries) 3 August 11th 08 12:42 PM
Debug Error Todd Huttenstine[_2_] Excel Programming 3 December 26th 03 11:46 PM


All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"