Unfortunately, it depends on what you are doing and how Excel is set up. If
Application.DisplayAlerts (this is VBA syntax) is false, Excel will open the file as read only without notifying the user. It may be possible to do this and then ask Excel if the file is read only, which, if the file was opened RW, might do the job - I hadn't previously thought of this, and will look into it (it's one in the morning, so not now!). If
Application.DisplayAlerts is true, a dialogue box will appear, but I haven't found a way to intercept it and process the message.
MerryMonk's node,
Is an Excel spreadsheet open?, drew responses about how to tell if a
single open instance of Excel has a file open, but as I said in that thread, what if someone has several instances of Excel open? I do, routinely. Therefore, I don't know of a better way within Excel/Perl than the "try to write" approach
MerryMonk mentioned.
Many thanks,
Marshall, for the link to the Handle download. I haven't previously hear of it, and I can see all sorts of applications. But, as you point out, it's not useful for applications for lowly users.
Regards,
John Davies
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.