Dave
Wed Jul 23 21:16:15 CDT 2008
#1. I don't think you can. But I'll wait for someone to chime in with a
definitive answer.
#2. It could be.
ExcelMonkey wrote:
>
> Yup that did it. 2 quick questions:
>
> 1) How do you change those VBE settings via VBA code?
> 2) If were doing this in VB.Net, would this be an issue?
>
> Thanks
>
> EM
>
> "Dave Peterson" wrote:
>
> > Try checking/changing a setting:
> > Inside the VBE
> > tools|options|general tab
> > Check "break in class module"
> >
> > I'm betting you have "break on all errors" checked.
> >
> >
> >
> > ExcelMonkey wrote:
> > >
> > > I am using the same code and it still does not work. My code stops on the
> > > Set stmt and prompts me with a VBA error dialog box. Could it be that I have
> > > a setting in VBA set? I am doing this in my Personal.XLS workbook. I tried
> > > it in a module in a regular xls file and I still get the same error. When I
> > > type the password in corrrectly the code works fine. I am in Excel 2003/SP3
> > > using XP.
> > >
> > > The code is below.
> > >
> > > Sub OpenFile()
> > > Dim myBook As Workbook
> > >
> > > Set myBook = Nothing
> > > On Error Resume Next
> > > Set myBook = Workbooks.Open(Filename:="C:\Documents and Settings\Our
> > > Account\My Documents\Test File.xls", Password:="a")
> > > On Error GoTo 0
> > >
> > > If myBook Is Nothing Then
> > > MsgBox ("Password was not correct.")
> > > Else
> > > MsgBox ("Password was correct.")
> > > End If
> > >
> > > End Sub
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > I think you changed the code.
> > > >
> > > > This minor alteration of Ron's code worked fine for me:
> > > >
> > > > Dim myBook As Workbook
> > > >
> > > > Set myBook = Nothing
> > > > On Error Resume Next
> > > > Set myBook = Workbooks.Open(Filename:="c:\book1.xls", Password:="a")
> > > > On Error GoTo 0
> > > >
> > > > If myBook Is Nothing Then
> > > > MsgBox "Not opened"
> > > > Else
> > > > MsgBox "Opened"
> > > > End If
> > > >
> > > > ExcelMonkey wrote:
> > > > >
> > > > > Is the Error Handling failing because I am using a Method after the Set stmt?
> > > > >
> > > > > Set mybook = Workbooks.Open(...)
> > > > >
> > > > > I cannot get On Error Goto to work either. The code always stops on the Set
> > > > > stmt and prompts me with an error.
> > > > >
> > > > > Thanks
> > > > >
> > > > > EM
> > > > >
> > > > > "ExcelMonkey" wrote:
> > > > >
> > > > > > Ron when I do this I am still prompted with the password dialog box. I do
> > > > > > not want to be prompted with this. How do I get arround this?
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > EM
> > > > > >
> > > > > > "Ron de Bruin" wrote:
> > > > > >
> > > > > > > You can use a on error
> > > > > > >
> > > > > > > Set mybook = Nothing
> > > > > > > On Error Resume Next
> > > > > > > Set mybook = Workbooks.Open(......................)
> > > > > > > On Error GoTo 0
> > > > > > >
> > > > > > > If Not mybook Is Nothing Then
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > >
> > > > > > > Regards Ron de Bruin
> > > > > > >
http://www.rondebruin.nl/tips.htm
> > > > > > >
> > > > > > >
> > > > > > > "ExcelMonkey" <ExcelMonkey@discussions.microsoft.com> wrote in message news:793DC95C-A19E-480F-B4A4-0230A74D2C67@microsoft.com...
> > > > > > > > How do you test to see if a workbook requires a passord prior to opening?
> > > > > > > >
> > > > > > > > Thanks
> > > > > > > >
> > > > > > > > EM
> > > > > > >
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >
> >
> > --
> >
> > Dave Peterson
> >
--
Dave Peterson