Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Test to see if Workbook requires a password

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" wrote in message ...
How do you test to see if a workbook requires a passord prior to opening?

Thanks

EM


--

Dave Peterson

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Test to see if Workbook requires a password

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" wrote in message ...
How do you test to see if a workbook requires a passord prior to opening?

Thanks

EM


--

Dave Peterson


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Test to see if Workbook requires a password

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" wrote in message ...
How do you test to see if a workbook requires a passord prior to opening?

Thanks

EM


--

Dave Peterson


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Test to see if Workbook requires a password

#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" wrote in message ...
How do you test to see if a workbook requires a passord prior to opening?

Thanks

EM


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Webquery for page that requires login and password JJ Excel Programming 0 February 8th 07 07:55 PM
Excel app now requires password VanS[_2_] Excel Programming 2 February 25th 06 09:27 PM
How do I get external web data that requires a password? praskal Excel Programming 1 April 7th 05 11:36 AM
Need code that requires password every 120 days bruce forster Excel Programming 2 May 6th 04 05:16 AM
How to record a New Web Query that requires login + password. J e r Excel Programming 2 February 13th 04 12:34 PM


All times are GMT +1. The time now is 11:34 AM.

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"