PDA

View Full Version : Solved: Opening workbooks



The Tamer
10-20-2004, 02:08 PM
Hi, I need vba to do the following when this workbook is opened:

1) check whether the book opened read only

2) (if it DID open read-only) compare the ID of the other person who has it open from a list that i will put in a sheet called "I.D. list", The names will be in column B (rows 1-30) and their IDs in column A
2a) if it finds an I.d. match in the list, a message box will say the name of the person
2b) if not it will say it can't find a match.

3) (if it did NOT open read only) it will tell the user to do their work as quickly as possible, then to get out!

Ideally, I would like it to substitute the read-only option box for the above, but am i correct to assume that, until a person actually elects to open the book, no macros will be looked at anyway?

I would appreciate help on this as it is a big problem in work, and it?s a report that I'm revamping and will have to maintain.

Thanks

Jacob Hilderbrand
10-20-2004, 02:16 PM
This will check if the workbook is Read Only.

Option Explicit

Sub ReadOnly()

Dim ReadOnly As Boolean

ReadOnly = ThisWorkbook.ReadOnly
MsgBox ReadOnly

End Sub

Jacob Hilderbrand
10-20-2004, 02:19 PM
You can display a message like this.

Option Explicit

Sub Message()

Dim Prompt As String
Dim Title As String

Prompt = "Hurry the **** up!! You only have a few minutes..."
Title = "Stop Wasting Your Time Reading This Title And Get Back To Work!!!"
MsgBox Prompt, vbCritical, Title

End Sub

Jacob Hilderbrand
10-20-2004, 02:20 PM
Also if you have multiple people working on the workbook, why not share it so up to 256 people can have it open at once?

The Tamer
10-20-2004, 03:28 PM
Hey Jake,

thanks for this, VBA coding isn't my strong point!

... with that in mind, can i trouble you with one more question?

How do I get your first piece of code to becom an IF statement, so that if its true, it'll run the second part of the code?

Cheers mate.

(Whats your highest snake score? - and on what type of phone?)

The Tamer
10-20-2004, 03:30 PM
Also if you have multiple people working on the workbook, why not share it so up to 256 people can have it open at once?Because my bosses have asked to switch shared access off. Also, the workbook has a lot of macros which seem to run into trouble when they're executed in shared state.

Cheers.

Damo

Zack Barresse
10-20-2004, 03:43 PM
Something like this Tamer ...


Sub ReadOnly()
Dim ReadOnly As Boolean
ReadOnly = ThisWorkbook.ReadOnly
If ReadOnly = True Then
Message
End If
End Sub
Sub Message()
Dim Prompt As String
Dim Title As String
Prompt = "Hurry the **** up!! You only have a few minutes..."
Title = "Stop Wasting Your Time Reading This Title And Get Back To Work!!!"
MsgBox Prompt, vbCritical, Title
End Sub

The Tamer
10-20-2004, 03:45 PM
Cheers both,

i'll buy you a donut!

Jacob Hilderbrand
10-20-2004, 05:08 PM
You're Welcome :)

Don't buy Zack any donuts. He already ate mine and Anne's and Scott's and everyone elses from the last two meetings we had. :mkay

My highest Snake score is 3550 on this site. I never played it on a phone. In fact I had never played the game before I found it here.

Zack Barresse
10-20-2004, 09:14 PM
Donuts! Yeah, yeah, yeah! :heehee

johnske
10-20-2004, 09:29 PM
If you REALLY wanna hurry them up, why not put a timer in there so the book closes when it times out?? (snigger, snigger) :bink: