LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You can protect your code within the VBE via:
tools|vbaproject properties|protection tab

Then when your code blows up, the users won't get the debug option.

But better would be to catch the password error and code around it:

Option Explicit
Sub testme()

Dim okToContinue As Boolean
Dim wkbkName As String
Dim wkbk As Workbook

wkbkName = "C:\my documents\excel\book1.xls"

Set wkbk = Nothing
On Error Resume Next
Set wkbk = Workbooks.Open(Filename:=wkbkName)
On Error GoTo 0

If wkbk Is Nothing Then
MsgBox "You didn't open the workbook!"
Exit Sub 'or whatever you want
End If

MsgBox wkbk.FullName

End Sub

====
Is there a reason you don't want your macro to supply the password to the second
workbook?

You could add it on the .open line:

Set wkbk = Workbooks.Open(Filename:=wkbkName, Password:="a")

H the Layman wrote:

I am opening a password protected Excel file from a button assigned with a
macro. However, when i press the button all works fine, the password box
appears for the file. if i enter the pass the file opens fine. The problem
occurs if i cancel the password request. The "debug" box appears and then
goes into editor mode. I do not want this to happen as it presents users with
an opportunity to hack away at the code!!!! Can I stop this from happening?
if so, could somebody please explain how to go about it, in laymans terms....
:) thanks in advance,


--

Dave Peterson
 
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
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
How Do I open an excel file without Excel Viewer support CocoriteBallGiants Excel Discussion (Misc queries) 2 February 4th 05 10:50 PM
how to turn off email header with excel workbook larhere Excel Discussion (Misc queries) 0 January 5th 05 12:39 AM
Turn off Assistance pane in Excel Petra Excel Discussion (Misc queries) 1 December 1st 04 02:19 AM
Why do formulas turn to values wen copying in Excel 2003... zyphyl Excel Worksheet Functions 1 November 6th 04 06:33 AM


All times are GMT +1. The time now is 04:10 PM.

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

About Us

"It's about Microsoft Excel"