Powerpoint Question

CT Witter

MrExcel MVP
Joined
Jul 7, 2002
Messages
1,212
Wondering if anyone has a way to include the username on a powerpoint presentation??

There doesn't seem to be any built in methods like word or excel.

Someone has been printing out my docs and I want to know who!!



Thanks,
CT
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi if you have Ppt 2k or later then this may be of interest to you. This obtains users login ID and the time when the ppt file is opened, and writes these details to a text file. You can then periodically look at the log and see who has been accessing the file.

For this to work you must download & install the AutoEvents addin from here http://www.mvps.org/skp/autoevents.htm. This gets you access to Ppt events such as Auto_Open.

Place this code in a Class Module
Rich (BB code):
Option Explicit

Public WithEvents App As Application

Private Sub App_PresentationOpen(ByVal Pres As Presentation)
Call LogUser
End Sub

Place this code in a standard module
Rich (BB code):
'Public declarations. These 2 lines must be before all procedures
Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Dim X As New EventClassModule
Sub InitializeApp()
    Set X.App = Application
End Sub

Sub Auto_Open()
Call InitializeApp
End Sub

Function ReturnUserName() As String
'Courtesy of http://www.exceltip.com/show_tip/Cu...er_name_using_VBA_in_Microsoft_Excel/452.html

' returns the NT Domain User Name
Dim rString As String * 255, sLen As Long, tString As String
    tString = ""
    On Error Resume Next
    sLen = GetUserName(rString, 255)
    sLen = InStr(1, rString, Chr(0))
    If sLen > 0 Then
        tString = Left(rString, sLen - 1)
    Else
        tString = rString
    End If
    On Error GoTo 0
    ReturnUserName = UCase(Trim(tString))
End Function

Sub LogUser()
Dim FileNum As Integer, FilePath As String

'Set path to log file
FilePath = "c:\LogTest.txt"  'change this to a network folder everyone has access to

'Obtain next free IO number
FileNum = FreeFile()

'Open file
Open FilePath For Append As #FileNum

'Write user login and todays date and time to textfile
Write #FileNum, ReturnUserName, Now()

' Close file.
Close #FileNum

End Sub

Note that I havent tested this as I only have office 97 at work.

hth
 
Upvote 0
Thanks for the suggestion!!

It isn't exactly what I want ( I can't run macros at work), but it will work for something else that I'm working on.

Thanks for your help

CT
 
Upvote 0

Forum statistics

Threads
1,216,128
Messages
6,129,030
Members
449,482
Latest member
al mugheen

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