Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Password issue

I have a template file which I limit access to by requiring a password to
open it. What I have done is put a button on the worksheet which allows the
user to start a new week based in the Template file. The code opens the
Template file and then renames the file based on the date the user selects
(this command button is on a dialog box with a calendar control). The
problem is, that when it opens the Template file it wants the password. How
can I get around this?





Private Sub CommandButton1_Click()

Unload SelectDate

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) +
5)

Application.ScreenUpdating = False

Sheets("Sunday").Select

Range("A2").Select

ActiveWorkbook.Save

Application.EnableEvents = False

Workbooks.Open(Filename:= _
"P:\SPECDISP\VEH_SCHD\DailyDriverSched.xls" _
).RunAutoMacros Which:=xlAutoOpen

Application.EnableEvents = True

Sheets("Sunday").Select
Range("B3").Select

If Weekday(Calendar1.Value) < 1 Then GoTo Error Else GoTo Continue

Continue:

Range("I1").Select

ActiveCell = Calendar1.Value

Sheets("Sunday").Range("A1001").Value = "gggg"

ActiveWorkbook.SaveAs Filename:="P:\PT_Driver_Sched\Daily Driver\ " &
Worksheets("Sunday").[I2].Value & ", " & " Week of " &
Worksheets("Sunday").[I3].Value & ", Daily Driver", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Sheets("Sunday").Select
Range("A2").Select

Application.ScreenUpdating = True

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) +
5)

GoTo EndMacro

Error:

SundayWarning.Show

EndMacro:

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Password issue

You can provide the password in your VBA code, using the Workbooks.Open method:

Workbooks.Open Filename:="D:\Data\Book1.xlt", Password:="aaa"

Hope this helps,

Hutch

"Patrick C. Simonds" wrote:

I have a template file which I limit access to by requiring a password to
open it. What I have done is put a button on the worksheet which allows the
user to start a new week based in the Template file. The code opens the
Template file and then renames the file based on the date the user selects
(this command button is on a dialog box with a calendar control). The
problem is, that when it opens the Template file it wants the password. How
can I get around this?





Private Sub CommandButton1_Click()

Unload SelectDate

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) +
5)

Application.ScreenUpdating = False

Sheets("Sunday").Select

Range("A2").Select

ActiveWorkbook.Save

Application.EnableEvents = False

Workbooks.Open(Filename:= _
"P:\SPECDISP\VEH_SCHD\DailyDriverSched.xls" _
).RunAutoMacros Which:=xlAutoOpen

Application.EnableEvents = True

Sheets("Sunday").Select
Range("B3").Select

If Weekday(Calendar1.Value) < 1 Then GoTo Error Else GoTo Continue

Continue:

Range("I1").Select

ActiveCell = Calendar1.Value

Sheets("Sunday").Range("A1001").Value = "gggg"

ActiveWorkbook.SaveAs Filename:="P:\PT_Driver_Sched\Daily Driver\ " &
Worksheets("Sunday").[I2].Value & ", " & " Week of " &
Worksheets("Sunday").[I3].Value & ", Daily Driver", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Sheets("Sunday").Select
Range("A2").Select

Application.ScreenUpdating = True

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now()) +
5)

GoTo EndMacro

Error:

SundayWarning.Show

EndMacro:

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Password issue

Tried as you sugested (code is below), but I still get asked for the
password when it opens the Workbook.


Workbooks.Open Filename:="P:\SPECDISP\VEH_SCHD\DailyDriverSched.x ls",
Password:="h2o"


"Tom Hutchins" wrote in message
...
You can provide the password in your VBA code, using the Workbooks.Open
method:

Workbooks.Open Filename:="D:\Data\Book1.xlt", Password:="aaa"

Hope this helps,

Hutch

"Patrick C. Simonds" wrote:

I have a template file which I limit access to by requiring a password to
open it. What I have done is put a button on the worksheet which allows
the
user to start a new week based in the Template file. The code opens the
Template file and then renames the file based on the date the user
selects
(this command button is on a dialog box with a calendar control). The
problem is, that when it opens the Template file it wants the password.
How
can I get around this?





Private Sub CommandButton1_Click()

Unload SelectDate

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now())
+
5)

Application.ScreenUpdating = False

Sheets("Sunday").Select

Range("A2").Select

ActiveWorkbook.Save

Application.EnableEvents = False

Workbooks.Open(Filename:= _
"P:\SPECDISP\VEH_SCHD\DailyDriverSched.xls" _
).RunAutoMacros Which:=xlAutoOpen

Application.EnableEvents = True

Sheets("Sunday").Select
Range("B3").Select

If Weekday(Calendar1.Value) < 1 Then GoTo Error Else GoTo Continue

Continue:

Range("I1").Select

ActiveCell = Calendar1.Value

Sheets("Sunday").Range("A1001").Value = "gggg"

ActiveWorkbook.SaveAs Filename:="P:\PT_Driver_Sched\Daily Driver\ " &
Worksheets("Sunday").[I2].Value & ", " & " Week of " &
Worksheets("Sunday").[I3].Value & ", Daily Driver", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Sheets("Sunday").Select
Range("A2").Select

Application.ScreenUpdating = True

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now())
+
5)

GoTo EndMacro

Error:

SundayWarning.Show

EndMacro:

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Password issue

When you set the password during a Save As operation, you can set a password
to open, a password to modify, or both. The code I posted sends the password
to open the file. If you set a password to modify, you need to use the
WriteResPassword argument instead. Here is an example where both kinds of
passwords were set for the workbook:

Workbooks.Open Filename:="D:\Data\Book1.xls", _
Password:="aaa", WriteResPassword:="bbb"

My guess is that you have a password to modify set for your workbook,
instead of or in addition to a password to open.

Hutch

"Patrick C. Simonds" wrote:

Tried as you sugested (code is below), but I still get asked for the
password when it opens the Workbook.


Workbooks.Open Filename:="P:\SPECDISP\VEH_SCHD\DailyDriverSched.x ls",
Password:="h2o"


"Tom Hutchins" wrote in message
...
You can provide the password in your VBA code, using the Workbooks.Open
method:

Workbooks.Open Filename:="D:\Data\Book1.xlt", Password:="aaa"

Hope this helps,

Hutch

"Patrick C. Simonds" wrote:

I have a template file which I limit access to by requiring a password to
open it. What I have done is put a button on the worksheet which allows
the
user to start a new week based in the Template file. The code opens the
Template file and then renames the file based on the date the user
selects
(this command button is on a dialog box with a calendar control). The
problem is, that when it opens the Template file it wants the password.
How
can I get around this?





Private Sub CommandButton1_Click()

Unload SelectDate

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now())
+
5)

Application.ScreenUpdating = False

Sheets("Sunday").Select

Range("A2").Select

ActiveWorkbook.Save

Application.EnableEvents = False

Workbooks.Open(Filename:= _
"P:\SPECDISP\VEH_SCHD\DailyDriverSched.xls" _
).RunAutoMacros Which:=xlAutoOpen

Application.EnableEvents = True

Sheets("Sunday").Select
Range("B3").Select

If Weekday(Calendar1.Value) < 1 Then GoTo Error Else GoTo Continue

Continue:

Range("I1").Select

ActiveCell = Calendar1.Value

Sheets("Sunday").Range("A1001").Value = "gggg"

ActiveWorkbook.SaveAs Filename:="P:\PT_Driver_Sched\Daily Driver\ " &
Worksheets("Sunday").[I2].Value & ", " & " Week of " &
Worksheets("Sunday").[I3].Value & ", Daily Driver", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Sheets("Sunday").Select
Range("A2").Select

Application.ScreenUpdating = True

Application.Wait TimeSerial(Hour(Now()), Minute(Now()), Second(Now())
+
5)

GoTo EndMacro

Error:

SundayWarning.Show

EndMacro:

End Sub




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Password issue

Thanks for your help!


"Tom Hutchins" wrote in message
...
When you set the password during a Save As operation, you can set a
password
to open, a password to modify, or both. The code I posted sends the
password
to open the file. If you set a password to modify, you need to use the
WriteResPassword argument instead. Here is an example where both kinds of
passwords were set for the workbook:

Workbooks.Open Filename:="D:\Data\Book1.xls", _
Password:="aaa", WriteResPassword:="bbb"

My guess is that you have a password to modify set for your workbook,
instead of or in addition to a password to open.

Hutch

"Patrick C. Simonds" wrote:

Tried as you sugested (code is below), but I still get asked for the
password when it opens the Workbook.


Workbooks.Open Filename:="P:\SPECDISP\VEH_SCHD\DailyDriverSched.x ls",
Password:="h2o"


"Tom Hutchins" wrote in message
...
You can provide the password in your VBA code, using the Workbooks.Open
method:

Workbooks.Open Filename:="D:\Data\Book1.xlt", Password:="aaa"

Hope this helps,

Hutch

"Patrick C. Simonds" wrote:

I have a template file which I limit access to by requiring a password
to
open it. What I have done is put a button on the worksheet which
allows
the
user to start a new week based in the Template file. The code opens
the
Template file and then renames the file based on the date the user
selects
(this command button is on a dialog box with a calendar control). The
problem is, that when it opens the Template file it wants the
password.
How
can I get around this?





Private Sub CommandButton1_Click()

Unload SelectDate

Application.Wait TimeSerial(Hour(Now()), Minute(Now()),
Second(Now())
+
5)

Application.ScreenUpdating = False

Sheets("Sunday").Select

Range("A2").Select

ActiveWorkbook.Save

Application.EnableEvents = False

Workbooks.Open(Filename:= _
"P:\SPECDISP\VEH_SCHD\DailyDriverSched.xls" _
).RunAutoMacros Which:=xlAutoOpen

Application.EnableEvents = True

Sheets("Sunday").Select
Range("B3").Select

If Weekday(Calendar1.Value) < 1 Then GoTo Error Else GoTo
Continue

Continue:

Range("I1").Select

ActiveCell = Calendar1.Value

Sheets("Sunday").Range("A1001").Value = "gggg"

ActiveWorkbook.SaveAs Filename:="P:\PT_Driver_Sched\Daily Driver\ "
&
Worksheets("Sunday").[I2].Value & ", " & " Week of " &
Worksheets("Sunday").[I3].Value & ", Daily Driver", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Sheets("Sunday").Select
Range("A2").Select

Application.ScreenUpdating = True

Application.Wait TimeSerial(Hour(Now()), Minute(Now()),
Second(Now())
+
5)

GoTo EndMacro

Error:

SundayWarning.Show

EndMacro:

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
How can I solve the issue of forgotten password in "sheet"? Marzi Excel Discussion (Misc queries) 1 August 6th 08 12:49 PM
Excel Worksheet Password Issue!!!!! nitro Excel Discussion (Misc queries) 2 June 29th 07 10:42 AM
PASSWORD REMOVAL I have the password to open the file and the password to modify the file now how to remove them LJ[_4_] Excel Programming 0 April 27th 06 03:18 AM
Password Issue keithl816 Excel Discussion (Misc queries) 6 July 10th 05 06:20 PM
how to automate opening a password protected excel file? e.g. a .xls that has a password set in the security tab. Daniel Excel Worksheet Functions 0 June 23rd 05 11:56 PM


All times are GMT +1. The time now is 10:41 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"