If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Using passwords in excel macros

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-19-04, 17:08
aaroncoppersmit aaroncoppersmit is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Cool Using passwords in excel macros

I am trying to create a macro that will open other password protected excel spreadsheets, update links, save and close.

The problem is that the macro always gets hung up on the password.

Is there a way to have the macro keyed in the password and continue?
Reply With Quote
  #2 (permalink)  
Old 02-19-04, 17:24
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Welcome to the Board!

Doesn't the Password Dialogue box come up when you execute your macro? It should wait until you have entered the password and then continue.

Smitty
Reply With Quote
  #3 (permalink)  
Old 02-19-04, 18:08
aaroncoppersmit aaroncoppersmit is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
The password dialog does come up, which is fine. I placed the opening of the password protected sheets at the beginning of the macro so I can start the macro, enter the password, then let the macro continue.

However, I am trying to set up a third party scheduling program (Wintask) to run the program automatically every night at 2:00 a.m. when no one is using the spreadsheets. (If anyone is using the spreadsheets, the macro gets hung up).

In order to run the scheduling program this way, I need it to automatically enter the passwords, because I'll be home asleep!

Do you know of a way for the macro to key the info in without getting hung up?
Reply With Quote
  #4 (permalink)  
Old 02-20-04, 10:27
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
I use this to unprotext a workbook/worksheet to make changes, and then reprotect before closing. Is this what you had in mind?


Code:
Sub UpdateExtraHdrFtr()

'Unprotects Worksheet
    ActiveWorkbook.Unprotect Password:="password"

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets
    ws.Unprotect Password:="password"
    Next ws
Application.ScreenUpdating = False

'Changes Headers and Footers
    Sheets("Extra").Select
    ActiveSheet.PageSetup.PrintArea = ""
    With ActiveSheet.PageSetup
        .LeftHeader = "Data Date: 02/15/2004"
        .CenterHeader = "&""Arial,Bold""&12Details"
        .RightHeader = "Print Date: &D"
        
    End With
Application.ScreenUpdating = True
    
    Sheets("Qtr Charts").Select


End Sub
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #5 (permalink)  
Old 02-20-04, 11:06
aaroncoppersmit aaroncoppersmit is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Thanks, Shades.

Actually, the password that I need to insert is used to open a protected workbook. I believe that your macro unprotects the worsheet once it is open, if the workbook is protected for editing.

The macro that I am using tries to open a protected spreadsheet, then gets hung up when the password dialog box opens.

Your macro refere to "activesheet", but I don't think that the sheet is active until it is actually opened.

Any ideas?


Thanks,

Aaron
Reply With Quote
  #6 (permalink)  
Old 02-22-04, 00:44
e_jaber e_jaber is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Use this function in your code that runs to open the protected workbook >>
Application.Workbooks.Open (FileName,True,False,,"Password","Password", ect...)
Good Luck
Esam
Reply With Quote
  #7 (permalink)  
Old 02-23-04, 11:23
aaroncoppersmit aaroncoppersmit is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Smile

Esam,

You stated "Use this function in your code that runs to open the protected workbook >>
Application.Workbooks.Open (FileName,True,False,,"Password","Password", ect...)"

Sorry, I'm pretty inept at this...

This is the part of my code that I'm trying to modify:

Workbooks.Open Filename:= _
"X:\BP Documents\Excel Documents\Time Sheets\BP Budgeted Hours.xls", _
UpdateLinks:=3

Can you help me to modify your code to open this sheet with the following parameters?:

1) Enable Macros.
2) Password is "Open".
3) Automatically update links.

If you can help me out, I'll have a major problem solved for a process that I am using at work!!!

Thanks!!!
Reply With Quote
  #8 (permalink)  
Old 02-23-04, 18:08
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Code:
Application.Workbooks.Open ("X:\BP Documents\Excel Documents\Time Sheets\BP Budgeted Hours.xls", _ 
True,False,,"Password","Password")
The frist "True" is to Update links. As for getting around Macro Security, if you could any Virus could as well. You can set it to LOW if you trust yourself or the files, or get a Digital Certificate.

Hope that helps,

Smitty
Reply With Quote
  #9 (permalink)  
Old 02-25-04, 14:55
e_jaber e_jaber is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Problem Solved

All,
Aron sent me a private email and I answered him ..
here are copies ..
Thanks
__________________________________________________ _______
Aaron>>

Thanks, Esam.

It worked - you're awesome!

Aaron
__________________________________________________ _______
Esam>>

Hello,
Here is the command line
Application.Workbooks.Open "X:\BP Documents\Excel Documents\Time Sheets\BP
Budgeted Hours.xls", True, False, , "open","open"
The password is case sensitive
Good Luck
Esam

__________________________________________________ _______
Aaron>>

>Thanks for posting, and thanks for your help! I'm not sure that you get an
>email when I reply, so I'm sending this direct.
>
>Here is my reply:
>
>You stated "Use this function in your code that runs to open the protected
>workbook >>
>Application.Workbooks.Open (FileName,True,False,,"Password","Password",
>ect...)"
>
>Sorry, I'm pretty inept at this...
>
>This is the part of my code that I'm trying to modify:
>
>Workbooks.Open Filename:= _
>"X:\BP Documents\Excel Documents\Time Sheets\BP Budgeted Hours.xls", _
>UpdateLinks:=3
>
>Can you help me to modify your code to open this sheet with the following
>parameters?:
>
>1) Enable Macros.
>2) Password is "Open".
>3) Automatically update links.
>
>If you can help me out, I'll have a major problem solved for a process that
>I am using at work!!!
>
>Thanks!!!
Reply With Quote
  #10 (permalink)  
Old 02-25-04, 15:11
aaroncoppersmit aaroncoppersmit is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Esam's code got me past the password.

I am trying to get a scheduling program to open an excel sheet and run macros at night when no one is using the other excel files accessed by the macro.

Unfortunately, as Smitty mentioned, I can't get a separate scheduling program (Wintask) to open the file and run a macro, because Excel doesn't seem to allow any outside program to automatically enable macros. This would allow viruses to get through.

I am looking into a digital certificate. Does anyone know where to get one? does it cost $$$? I am assuming that if I certify the macros within excel, the "enable macros" dialog won't even come up if I list my digital certificate as a trusted source. I haven't actually tried this yet, so I don't know if it will work.

I was also thinking of doing a self certification instead of the digital certificate, but the Microsoft executable for doing so states that other users may not recognize the certification because it could be a forgery.

If anyone has thoughts on this, they would be much appreciated.

Thanks,

Aaron
Reply With Quote
  #11 (permalink)  
Old 02-25-04, 15:19
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Your IS Department should be able to set you up with a DigitalCertificate, but a Self-Certificate may well be an option.

Smitty
Reply With Quote
  #12 (permalink)  
Old 02-25-04, 15:55
e_jaber e_jaber is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Reset your Security

Aaron,
Here is an "unsafe" solution
set the macros security option on the required workbook to low then save.
You can do that this way ..
Excel Menu >> Tools >> Macros >> Security >> Option 3
That will remove the dialog and the macros will run automatically on open.
I have not tried that opening an xls file remotly, try and tell me.
Good Luck
Esam
Reply With Quote
  #13 (permalink)  
Old 02-25-04, 15:59
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Esam's alternative of setting Macro Security is unsafe unless you have a corporate level virus scan program installed.

My IS Department has me do that for all of my users as they won't (haven't figured out how to) give me a Digital Certificate. In 4+ years in this unit it's never been a problem.

Smitty
Reply With Quote
  #14 (permalink)  
Old 02-25-04, 16:04
aaroncoppersmit aaroncoppersmit is offline
Registered User
 
Join Date: Feb 2004
Posts: 13
Problem Completely Solved!!!

I tried Smitty's approach:

1) I self certified each computer on which the Macros will run.

2) I listed the certification as a "trusted source" in each macro.

3) I set the security level to "Medium".

4) The first time that I opened the spreadsheet, I had to click "Always trust this source" and save the file.

5) From then on, the "enable macro" dialog never came up again.

Thanks for all of your help, guys!

One more thing: I am looking for a schedule program that will open the excel file, run the macros, then save and close, and automatically notify me via email.

I am trying "Wintask", but it does not have the capability to email me. Does anyone know of a good scheduler that will do all of the above?

Thanks,

Aaron
Reply With Quote
  #15 (permalink)  
Old 02-25-04, 16:10
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Wintask - Is that the same as Programs-->Accessories-->System Tools-->Scheduled Tasks? (Sorry - I haven't used it before).

As for the e-mail, why not send it through Excel at the end of your code. What e-mail client are you using?

For Outlook, have a look here. It's about the most complete Outlook e-mail reference around.

http://www.rondebruin****/sendmail.htm

Smitty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On