Consulting

Results 1 to 11 of 11

Thread: Opening workbooks

  1. #1
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location

    Opening workbooks

    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

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    This will check if the workbook is Read Only.

    Option Explicit
    
    Sub ReadOnly()
    Dim ReadOnly        As Boolean
    ReadOnly = ThisWorkbook.ReadOnly
        MsgBox ReadOnly
    End Sub

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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?

  5. #5
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location
    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?)

  6. #6
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location
    Quote Originally Posted by DRJ
    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

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    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

  8. #8
    VBAX Contributor
    Joined
    Oct 2004
    Location
    Cardiff
    Posts
    120
    Location
    Cheers both,

    i'll buy you a donut!

  9. #9
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    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.

    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.

  10. #10
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Donuts! Yeah, yeah, yeah! :heehee

  11. #11
    Administrator
    Chat VP VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    If you REALLY wanna hurry them up, why not put a timer in there so the book closes when it times out?? (snigger, snigger)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •