Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter Password when requested by Excel?

Status
Not open for further replies.

esoare

Programmer
Jun 15, 2005
199
US
Hi all!

Looking at setting up procomm to open an excel file.
Set up a DDE with it, and get info for scripts and such.

The File is password protected though... So excel is asking for a password.

Is there a way for Procomm to enter a string in the "password" box and then press the enter key?

What is the value you may ask?
Well, if you have procomm on a box, and only the "Wax" file was on it, then the password for the excel file would be "encrypted" in a sense, yet you could still have secure data in an excel sheet that would have customer info on it.

I did searches on the site here, but couldn't see anything.
I looked at the help and found the V_Key stuff..Could someone verify if they are only applicable in the Procomm environment.

Could someone at Tek-Tips Please get the "SPELL CHECKER" to not Highlight the "Tek" and "Procomm" when we enter a message please?

:)

Hope your Saturdays are well
 
You can use the winactivate command to set the Excel prompt for the password as the active window and then use sendkeystr to send the password to that window, followed by a sendkey 0x0D to press the OK button in that dialog. The only tricky part may be if the title of the Excel dialog varies, for instance if the filename is part of the text and you are possibly opening various files.

 
Thanks knob! That got me going on the right track.
I gave it a shot, but the run command, would not finish because the password was not placed into the excel box.
Only after the "Password" dialog was closed with "cancel" or "OK" would the script continue.

I have it running in the following way, but if there is something that is cleaner let me know.

start is a bat file in the aspect directory.

/code in Aspect
string Ffile = "C:\passwordtest.xls"
string Secret
string Start = "start.bat"
Secret = "xxxxxxxx"

run start HIDDEN
pause 7
winactivate "Password"
winfocus "Password"
sendkeystr Secret
sendkey 0x0D
/endcode of Aspect

/code in batch file "start"
C:
cd\
passwordtest.xls
/endcode in batch file "start"


now, you may wonder why I did the HIDDEN command after the "run" command. The CMD box won't go away until after Excel is closed.

IF there is a way to use the run command on the Excel file directly and not rely on the batch file, that would be great.

To re-iterate what the problem with that is.
If the run command for the excel file is inside the aspect script, it will get stuck there until Excel is fully up (after the password box is gone). So it won't allow the winactivate etc.. to run.

Thanks for pointing me in the right direction!
es
 
I wonder if there is a way to specify the password in the command line that launches the spreadsheet so you could do away with the batch file entirely? It might be worth digging into Microsoft's knowledge base to see if that is a possibility.

 
Why do you use a batch file to open the document? It seems like that is causing more problems than it could possibly fix.

If you type the path and the filename of the excel document as the String for the "run" command, and it causes issues, try the DOS command. Then you wouldn't have to worry about the "hidden", or the script waiting for completion. A DOS command is sent and then forgotten and the script keeps going regardless. I would use the DOS command, (which even the ASPECT help will tell you to use if you want to start a batch file).

Here is a snippet of a script I just wrote yesterday which takes a list of I.P. addresses from a text file and sends the DOS command to PING them and send the results to another file. You will notice that other commands can be carried out while the DOS function is doing it's thing.

strfmt sCmdLine "ping %s >> %s" sLine sNATresults

dos sCmdLine HIDDEN iTask

STATmsg "Pinging %s" sLine

while taskexists iTask
TermWriteS "."
GetCur iRow2 iCol2
TimeLeft()
Pause 1
TimeLeft()
Pause 1
endwhile
GetCur iRow2 iCol2

sLine is the I.P. address that it pulled from the text file. sNATresults is the FileSpec of the output of the PING command (which always appends).

Why couldn't you use the DOS command to open the excel file and then send the Virtual Keystrokes to it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top