View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
paankadu paankadu is offline
external usenet poster
 
Posts: 15
Default Macro error when trying to open workbook

OK, I found my problem. There was a 3rd worksheet that it was trying to
unprotect, but it wasn't protected. I have corrected that. Sorry to have
bothered you with a silly error, but am glad I found it.

On the other hand, the code listed in the original post works great to put
in the date, but when the user does a file save as date_Furnace.xls and they
go to reopen it a few days later it doesn't keep the original date entered.
It changes it to the date the file is being opened. How do I keep the
original date entered? The main file Furnace.xls is being used as a master
file and then after they enter their log information it is being saved as
date_Furnace and that is where the date needs to remain static without
anything being done by the user.

Thanks again!
--
Thanks,
Angie


"paankadu" wrote:



Run-time error '1004':
The password you supplied is not correct. Verify that the CAPS LOCK key is
off and be sure to use the correct capitalization.

.Unprotect Password:="waste"

this is the line it errors out on first.

I have gone in and unprotected the workbook and reprotected it and made sure
everything is identical...like I said it has worked on the 1st 4 or 5
workbooks without a problem. Since many of the forms are very similar when i
have finished 1 workbook I do a file save as to the new name and go in and
change the protection passwords and the passwords in the code. It has done
this error on the last 2 workbooks now.


Also, when I have saved my original form from Furnace.xls to 11.5
Furnace.xls and go in and open up the 11.5 Furnace the date changes to the
current date. On the saved versions I need the date to remain what it was
originally entered as, not change to the current. How do I get it to remain
static on the saved copies. The Furnace.xls file will be the master form
that the user will go in each day and update and as they complete they will
save it as date_Furnace.xls

Thanks again!
Thanks again.


--
Thanks,
Angie


"Jacob Skaria" wrote:

Hi again

You havent mentioned what the error is..

"paankadu" wrote:

I have been using this macro in several workbooks... each has a spearate
password and it has been working great... until I get to my latest workbook

I protect the sheets and have this code in the "This Workbook" so when it
opens it will update the date in each worksheet.. I have gone in and verified
my password for each sheet, have taken the protection off and put it back on
being very careful to make sure I am not misspelling anything, have changed
passwords and keep getting the same error. This is the same code I have used
in about 7 other workbooks (just changing the password for each one). I have
even deleted the code out and typed it in from scratch.

Anyone have any ideas why I am getting this error on only 1 workbook?


Private Sub Workbook_Open()
Dim Sh As Worksheet
For Each Sh In Sheets
With Sh
.Unprotect Password:="bear"
.Range("g2") = Date
.Protect Password:="bear"
End With
Next
End Sub

--
Thanks,
Angie