Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Webquery for page that requires login and password | Excel Programming | |||
Excel app now requires password | Excel Programming | |||
How do I get external web data that requires a password? | Excel Programming | |||
Need code that requires password every 120 days | Excel Programming | |||
How to record a New Web Query that requires login + password. | Excel Programming |