rizmomin Posted March 5, 2008 Report Share Posted March 5, 2008 i would like to know how would i open Password Protected Excel file. i have macro to the point that it will open the excel sheet to thepoint of entering the password. Obviosly i have the Password to open the excel sheet which i am entering manually. Please help Quote Link to comment Share on other sites More sharing options...
Cory Posted March 5, 2008 Report Share Posted March 5, 2008 Can't you just Text Type the password after waiting for the password popup? Quote Link to comment Share on other sites More sharing options...
rizmomin Posted March 5, 2008 Author Report Share Posted March 5, 2008 Can't you just Text Type the password after waiting for the password popup? No...it would not take it within the macro... Riz Quote Link to comment Share on other sites More sharing options...
Cory Posted March 6, 2008 Report Share Posted March 6, 2008 Ahhhhhhhh now this was a fun one! Thanks for the challenge, I learned something by it. I tried reproducing your problem and was successful using Excel 2003. I’ll spare you the half hour of troubleshooting but what it comes down to is if you use the Program Launch by default it waits for the program to finish loading before it moves forward. I created a Launch for Excel with the file name as a parameter and added some debug. The problem is that until you type in the password ME doesn’t think Excel is done loading. I had put a Wait for Window Title in with a max of 5 seconds but the macro kept going, and going, and going… Way longer than 5 seconds. This is what tipped me off. Now I can think of a few workarounds. But the approach will be different depending on how you use the Activate/Launch Program command. Personally I just stick the file name in the program field and rely on the file association so when I distribute I don’t have to worry about programs having different paths but it doesn’t work right here. You see in the advanced tab there is an option where one can set the continue option “If the program fails to launch in the specified time:” but when I set it to Continue Macro it didn’t work. When I specify Excel and add the file path and name as a parameter it works. Also if I specify a file that does not require a password it works. But if I put the file name in the program field in Launch Only and there is a password protecting the file there is a 122 second delay before the If Program Fails action kicks in. Every time exactly 122 seconds. I don’t know why this is but I think it’s a bug. Also Joe makes some interesting comment about this in his book on page 288. I’ll have to ask him if I can make a citation. So I think your Activate/Launch is stuck and I think by changing the command parameters around as I described you should be able to get it to work. The key is understanding that this is where the pause is happening, not later in the script. Maybe there’s something I’m missing here and Kevin may be able to better comment. Maybe it’s not a bug but rather my user error. Quote Link to comment Share on other sites More sharing options...
Cory Posted March 6, 2008 Report Share Posted March 6, 2008 Per Joes book starting on page 288 talking about the If Program Fails options. Well, now for the interesting part. I can never get this Launch Program Only command to fail except when I purposely enter a bad program name. For example, I use StyleWriter as an editor, which always takes at least five seconds to load. Setting the Delay in Seconds value to zero or 1 never results in a failed launch. This is true of every program that I have tested. Your results may be different. Macro Express has no control over how Windows launches an application. Macro Express tells Windows what to launch. Windows does the rest … right or wrong. Quote Link to comment Share on other sites More sharing options...
kevin Posted March 6, 2008 Report Share Posted March 6, 2008 The Launch and Activate command asks Windows to load a program and then waits for the specified Window to get focus. It sounds like the main Excel window never gets focus. Try replacing the Launch and Activate command with something like this: Program Launch: "excel.exe" Wait For Window Title: "Excel" OR Wait For Window Title: "Password" Quote Link to comment Share on other sites More sharing options...
Cory Posted March 6, 2008 Report Share Posted March 6, 2008 Thanks for looking in on this Kevin. I tried as you suggest but it doesn't work. I put a beep in before the Wait For Window and it never beeps. IOW it's still stuck in the Launch command. And the Excel window title appears moments before the password box appears and is apparent in the background the entire time the password box comes up. It seems to me that the Fail to Load option isn't satisfied probably because it sees Excel is running in the processes. But whatever it's using to test that it was successful it doesn't see and keeps waiting for. And what's with the 122 second delay? Seems to me that should be some kind of indication of what's going wrong. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.