How to stay always “Available” in Microsoft Teams with Excel

How to stay always “Available” in Microsoft Teams with Excel

Or create your own Excel file by reading the text below (and copy / paste the vba code)

Why?

First it was a private joke, with this article it’s now a public joke.

Our client switched from Skype to Teams and it was a very cool improvement. My colleagues told me with a bit of fun: “Teams is cool, but you can’t change the time before appearing away!”. And it’s true, we can’t! Somebody said, “If you install a software who will click randomly on your screen, you will not appear away anymore”. Yes,.. but our software policy does not allow us to install anything on our computers.

It gave me an idea! Thanks to our very good old friend, Excel! People will say “Lazy is smart”, Arnaud is “funny” or any other reason. But I had fun with Excel and his perfect VBA editor.

My colleague Isabelle (and also Maslow) will say :

https://en.wiktionary.org/wiki/if_all_you_have_is_a_hammer,_everything_looks_like_a_nail

My hammer is Excel and Code.. I agree.. (nail or snail.. it’s just a “s” who is missing)

I created a small excel sheet who will loop until you ask it to finish and will move your mouse cursor every 5 seconds.

My joy is shared between.

“I’m the Microsoft BI guy who uses Microsoft Office and VBA code to do a joke”.

and

“People will see me as a very lazy guy!! isn’t the name of his website!?!”.

Anyway, if you read this article, then it’s because I think you will pick the first idea. I’m I wrong? 🙂

Where can you download it?

You can download the excel sheet on my github repo.

(If you want your own excel sheet, the code is also available at the end of this post)

Thanks to Rafi for his 64 bits version!

How does it look like?

This is how it looks in Excel. You can start the timer by clicking on the start button or CTRL + l (like lazysnail) or start manually the macro named “DoNotSleep”.

To stop the timer, you have to press any key.

Do you have the VBA code?

If you are curious and want to build your own Excel, let’s copy the following VBA code:

Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As LongPtr, ByVal y As LongPtr) As LongPtr
Public Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As LongPtr, ByVal dx As LongPtr, ByVal dy As LongPtr, ByVal cButtons As LongPtr, ByVal dwExtraInfo As LongPtr)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As LongPtr = &H8
Public Const MOUSEEVENTF_RIGHTUP As LongPtr = &H10

Sub DoNotSleepPlease()

Dim i As Integer

For i = 1 To 9999
    'For Info, number of iteration
    'Cells(1, 1) = i
    If Cells(3, 5) = "" Then
        SetCursorPos 200, 200 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
        
        
        SetCursorPos 300, 300 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
        
        SetCursorPos 400, 400 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
        
        SetCursorPos 500, 500 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
    Else
        Exit For
    End If
    Next i
End Sub


Sub WaitPlease()
    Dim sngWaitEnd As Single
    sngWaitEnd = Timer + 5
    Do
      DoEvents
      Cells(3, 3).Value = Timer
    Loop Until Timer >= sngWaitEnd
End Sub


Pin It on Pinterest