Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable printing!

Status
Not open for further replies.

tgoricki

Programmer
Feb 17, 2003
8
HR
modul:

Dim x As New Class3

Sub Register_Event_Handler()
Set x.appWord = Word.Application
End Sub

Class3:

Public WithEvents appWord As Word.Application
'-----------
Private Sub appWord_DocumentBeforePrint(ByVal Doc As Document, Cancel As Boolean)
MsgBox ("You can't print!")

Cancel = True
End Sub

This code is disabling printing!
Now I nead to be desabled for only some users. Can any1 tell me how can I knew which user is loged on the Windows?
 
If you are using Access security, then use CurrentUser to return the current user. If you are networked, then try this function.

Public Function GetNTUser() As String
'Returns the network login name
Dim strUserName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get user name
GetUserName strUserName, 100
'Strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
GetNTUser = strUserName
End Function

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top