Can't open a Read Only Spreadsheet

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
bobmcc81
Newbie
Posts: 4
Joined: Mon Dec 08, 2008 9:18 pm

Can't open a Read Only Spreadsheet

Post by bobmcc81 » Wed Dec 10, 2008 4:42 pm

I receive a read only spreadsheet daily that I am scripting to open, change tabs and then save as an ASCII text file. Everything is working fine except telling the spreadsheet I want it to open read only.

Below is an excerpt of my script and I have bolded where I try to press the hot key in the window that Excel opens to tell you the spreadsheet is read only. On the keyboard outside of scripting ALT-R or enter were perfectly but I can't get it to recognize in my script, the macro just hangs. The read only windows appears to be the active window.

Thanks for any tips

Bob

-------------------------------------


execute file>C:\Documents and Settings\v400678.US1\My Documents\Supply Point Scorecard\3 DOS\MMP Files\todaysfile.xls
WaitWindowOpen>Microsoft Excel - todaysfile.xls
setfocus>Microsoft Excel - todaysfile.xls
wait>3
press alt
wait>.2
send>R
wait>.2
release alt
wait>.2
press CTRL
wait>.2
press page up
wait>.2
release CTRL
wait>.2
press home
//save as ascii CSV file

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Dec 10, 2008 5:05 pm

Not sure what this had to do with a beta version so I have moved it to General.

When you debug the script how far does it get?

Have you tried:

Press ALT
Send>r
Release ALT
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Dec 10, 2008 5:14 pm

Curious.
Just tried pressing ALT+r manually in an open excel file and it does nothing. Is ALT+r a shortcut to an Excel macro you have written? What version of Excel are you using? I'm still on 2003.

the following line will open an excel file in readonly mode:

Run>C:\Program Files\Microsoft Office\OFFICE11\Excel.exe /r c:\File.xls

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Dec 10, 2008 7:22 pm

JRL: If the spreadsheet is saved with a password needed to modify, then when it is opened you get a little popup with the choice to either enter the password or push a button to open it read only. Alt R is the equivalent of pushing the read only button.

Maybe he needs to set focus on the popup before sending the Alt R? (The main window name doesn't reflect the name of the file until it is open - at least if you open the file by clicking on it.)

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Dec 10, 2008 7:32 pm

Ah! So the problem is his script waits for the main Excel window to open and then immediately tries to send alt-r. Either it is sending the alt-r too soon - before the popup has appeared and therefore needs to wait for this popup; or, if the popup appears before the Excel window title contains the filename his WaitWindowOpen will wait forever.

OP: look at the flow of events - when does the popup appear. Does it appear after Excel's title contains the filename or before? What is its title?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Dec 10, 2008 7:42 pm

JRL's /r command line opens the file directly, so that would be a better way to go IMHO.

bobmcc81
Newbie
Posts: 4
Joined: Mon Dec 08, 2008 9:18 pm

Post by bobmcc81 » Thu Dec 11, 2008 3:48 pm

Sorry for the post in the wrong forum, my bad.

Thanks JRL that opening switch on Excel.exe was the trick thanks so much for everyone's help!

Bob

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts