Track User, Computer , Date When Excel Connection is refreshed

sgaru

New Member
Joined
Jun 22, 2016
Messages
2
[FONT=&quot]Hi All,[/FONT]
[FONT=&quot]I am fresher to VBA.I need to track and store the data of the users who refresh my Excel Work books. These excel work books are typically connected to OLAP Cubes. I need to get the values - Username, Computer name , Date when refreshed/Accessed to be loaded into my SQL Server database.[/FONT]
[FONT=&quot]Do you have any solutions for this? How do i start with this? Any resources which can help me are greatly appreciated.[/FONT]
[FONT=&quot]Thanks,[/FONT]
[FONT=&quot]SG[/FONT]
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
if you add this code and run it, then look in the immediate window you will see what is already available in the ENVIRON

Code:
Sub ListEnvironmentVariables()
'each environment variable in turn
Dim EnvironmentVariable As String
'the number of each environment variable
Dim EnvironmentVariableIndex As Integer
'get first environment variables
EnvironmentVariableIndex = 1
EnvironmentVariable = Environ(EnvironmentVariableIndex)
'loop over all environment variables till there are no more
Do Until EnvironmentVariable = ""
'get next e.v. and print out its value
Debug.Print EnvironmentVariableIndex, EnvironmentVariable
'go on to next one
EnvironmentVariableIndex = EnvironmentVariableIndex + 1
EnvironmentVariable = Environ(EnvironmentVariableIndex)
Loop
End Sub

Then using variations on
Code:
Private Sub Workbook_Open()
    Dim LastRow As Long
    LastRow = Sheets("tracker").Range("A100000").End(xlUp).Row
    LastRow = LastRow + 1
    With Sheets("tracker")
        .Range("A" & LastRow) = Now()
        .Range("B" & LastRow) = Environ("USERNAME")
        .Range("C" & LastRow) = Environ("COMPUTERNAME")
        .Range("D" & LastRow) = Environ("LOGONSERVER")
        .Range("E" & LastRow) = Environ("USERDNSDOMAIN")
    End With
End Sub

and combining it with your code on the cube refresh you could have a result
 
Upvote 0
Thanks for the quick reply. Where can I set up SQL connection so that I can write this information to the table directly.

Also how to write code for cube refresh? What method. Sorry for the beginner questions
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top