Tecnologia, programação e muito Visual FoxPro.

terça-feira, 29 de setembro de 2009

Re: ]] XL-mania [[ Workbook yg Rajin mencatat Nama Excel-User yg membukanya.

 

Penjelasannya ooom Sori Make bahasa Inggris maklum dapet dari cd MSDN he he he....


UserName Property

Returns or sets the user's name, which is used on envelopes and for the Author document property. Read/write String.

expression.UserName

expression Required. An expression that returns an Application object.

Example

This example sets the user's name.

Application.UserName = "Andrew Fuller"
                               

This example returns the name found in the Name box on the User Information tab in the Options dialog box (Tools menu).

Msgbox Application.UserName
                               

 

 

WshNetwork Object

Provides access to the shared resources on the network to which your computer is connected.

You create a WshNetwork object when you want to connect to network shares and network printers, disconnect from network shares and network printers, map or remove network shares, or access information about a user on the network.

 Example

The following example demonstrates displaying the domain name, computer name, and user name for the current computer system using the WshNetwork object.

<package>
   <job id="vbs">
      <script language="VBScript">
         Set WshNetwork = WScript.CreateObject("WScript.Network")
         WScript.Echo "Domain = " & WshNetwork.UserDomain
         WScript.Echo "Computer Name = " & WshNetwork.ComputerName
         WScript.Echo "User Name = " & WshNetwork.UserName
      </script>
   </job>   

 

Interaction..::.Environ Method (Int32)

Returns the string associated with an operating-system environment variable.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

Parameters

Expression

Type: System..::.Int32
Required. Expression that evaluates either a string containing the name of an environment variable, or an integer corresponding to the numeric order of an environment string in the environment-string table.

Return Value

Type: System..::.String
Returns the string associated with an operating-system environment variable.

 

************************************************************************************************


Di coba buat filenya menggunakan WshNetwork Object, Jika sebelumnya LogFilenya di write ke lokasi Folder "D:\MyLogFiles\" sekarang dicoba menyimpannya di dalam SHEET dan di HIDEN(Umpetin) biar gak ada yang tahu he he he .....

Kodingannya oom : Filenya Terlampir di Attachment oom
- Di dalam Modul
Sub Elog(Evnt As String)
   
  
    Application.ScreenUpdating = False
    Dim cRecord As Long
    cSheet = ActiveSheet.Name
   
    If CekSheet("Log") = False Then ' Cek nama sheet "Log"
        Sheets.Add.Name = "Log"
        Sheets("Log").Select
        ActiveSheet.Protect "Pswd", UserInterfaceOnly:=True
    End If
   
        Sheets("Log").Visible = True
        Sheets("Log").Select
        ActiveSheet.Protect "Pswd", UserInterfaceOnly:=True
       
        cRecord = Range("A1")
    If cRecord <= 2 Then
        cRecord = 3
        Range("A2").Value = "Event"
        Range("B2").Value = "Nama Pengguna"
        Range("C2").Value = "Nama Domain"
        Range("D2").Value = "Nama Komputer"
        Range("E2").Value = "Tanggal dan Waktu"
    End If
   
    If Len(Evnt) < 25 Then Evnt = Application.Rept(" ", 25 - Len(Evnt)) & Evnt
   
        ' Ok ini dia mencatat:
        ' Range A : Evnt (Lihat This Woork Book), Method yang dicatet :
            ' 1. Private Sub Workbook_BeforePrint = "Hapus"
            ' 2. Private Sub Workbook_BeforeSave = "Simpan File"
            ' 3. Private Sub Workbook_Open  = "Membuka File"
        ' Range B Nama Pengguna
        ' Range C Nama Domain (jaringan komputer)
        ' Nama Komputer (Identifikasi nama komputer dlm jar-kom
        Range("A" & cRecord).Value = Evnt
        Range("B" & cRecord).Value = Environ("UserName")
        Range("C" & cRecord).Value = Environ("USERDOMAIN")
        Range("D" & cRecord).Value = Environ("COMPUTERNAME")
        Range("E" & cRecord).Value = Now()
    cRecord = cRecord + 1
   
    If cRecord > 20002 Then
        Range("A3:A5002").Select
        dRows = Selection.Rows.Count
        Selection.EntireRow.Delete
        cRecord = cRecord - dRows
    End If
   
    Range("A1") = cRecord
    Columns.AutoFit
    Sheets(cSheet).Select
    Sheets("Log").Visible = xlVeryHidden
    Application.ScreenUpdating = True
   
End Sub
Function CekSheet(SheetName As String) As Boolean
    On Error GoTo SheetGakAda
    If Len(Sheets(SheetName).Name) > 0 Then
        CekSheet = True
        Exit Function
    End If
SheetGakAda:
        CekSheet = False
End Function
Sub Lihat_Log()
    Sheets("Log").Visible = True
    Sheets("Log").Select
End Sub
Sub Umpetin_Log()
    Sheets("Log").Visible = xlVeryHidden
End Sub

- DI This Woorkbook
' Buat nyatet kegiatan user
Private Sub Workbook_BeforePrint(Cancel As Boolean)

Dim Evnt As String
Evnt = "Hapus"
Call Elog(Evnt)
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim Evnt As String
Evnt = "Simpan File"
Call Elog(Evnt)
End Sub

Private Sub Workbook_Open()
Dim Evnt As String
Evnt = "Membuka File"
Call Elog(Evnt)
End Sub

************************************************************************************************

Saya gak tahu apa ini berhasil menyimpan Log Pengguna di dalam JARINGAN KOMPUTER LOKAL...he he maklum komputer ane dirumah cuman 1 Doank oom jadi gak bisa di Tes.......



~ ^ Puthut Wibowo ^ ~



--- On Fri, 9/25/09, kid <nmkid.family@gmail.com> wrote:

From: kid <nmkid.family@gmail.com>
Subject: Re: ]] XL-mania [[ Workbook yg Rajin mencatat Nama Excel-User yg membukanya.
To: XL-mania@yahoogroups.com
Date: Friday, September 25, 2009, 4:31 AM

 

Sik sik sik....
Boleh tahu dong bedanya Office Username sama Windows Username sama NetWork UserName apa ya..

Kalau di-share terus Office Username pake yang mana ya...
Terima kasih kalau mau memberi detilnya... biar tambah jelas.

Maksudnya, kalau login windows pake A, lalu buka excel maka Office userName-nya siapa
Kalau via network (share) dengan login B, lalu buka excel maka office username-nya siapa.

Regards.
Kid.

2009/9/24 Puthut Wibowo <puthut_vai@yahoo. com>
 

Tante2x..... ..Event : '   Application. UserName bukannya mendapatkan MS OFFICE Username yak Bukannya Windows (Yang dientry pada saat install windows) ???

He he bagusnya dapetin nama Windows Usernamenya jadi pas dishare juga ketahuan

Fungsinya :
Option Explicit
'api call for obtaining the username
Private Declare Function GetUserName& Lib "advapi32.dll" Alias "GetUserNameA" _
                 (ByVal lpBuffer As String, _
                 nSize As Long)
 
Public Function WindowsUserName() As String
    Dim szBuffer As String * 100
    Dim lBufferLen As Long
   
    lBufferLen = 100
   
    If CBool(GetUserName( szBuffer, lBufferLen)) Then

        WindowsUserName = Left$(szBuffer, lBufferLen - 1)
       
    Else
       
        WindowsUserName = CStr(Empty)
       
    End If
   
End Function

Kalo di modif dari punyanya Tante yang Misterius ( Katanya om Mono looh tante bukan saya) :

Private Sub Workbook_Open( )
   Call LogInfo( _
   Format(Now, "dd-mmm-yyyy hh:mm:ss") & " " & _
   "Opened by " & WindowsUserName)
End Sub


Selain itu ada fungsi lainnya (File Terlampir)
- Nama Environtment
Environ("USERNAME")

- NETWORK Username :
    Dim objNet As Object
    On Error Resume Next
    Set objNet = CreateObject("WScript.NetWork")
    MsgBox "Network username : " & objNet.UserName
    Set objNet = Nothing


~ Puthut Wibowo ~

--- On Mon, 9/21/09, siti Vi <setiyowati.devi@ gmail.com> wrote:

From: siti Vi <setiyowati.devi@ gmail.com>

Subject: ]] XL-mania [[ Workbook yg Rajin mencatat Nama Excel-User yg membukanya.
To: "XL-mania" <XL-mania@yahoogroup s.com>
Date: Monday, September 21, 2009, 12:49 PM

 

anda dapat membuat workbook yg memungkinkan otomatis tercatatnya
- nama excel user dan
- saat (date & time) / kapan user tsb membuka file ini


catatan ditulis dalam sebuah file text (LOGBOOK) yg di simpan di folder tertentu;
dlm contoh ( ./. ctv_AutoLogger_ Workbook. xls)
* folder = D:\MyLogFiles
* nama file = nama workbook; tetapi extensinya (xls) diganti Log

barangkali saja suatu saat anda memerlukan hal seperti ini yg akan anda
berlakukan terhadap file yg  sensitip, misal terhadap file "TOP SECRET" yg
berisi resep-resep rahasia anda.. Setiap saat anda dapat mengontrol:
siapa saja yg permah membuka workbook tsb.

untuk mencapai keinginan itu, diperlukan dua Prosedur Sub

prosedur I : memanfaatkan event Dibukanya Workbook
- jika workbook dibuka : otomatis prosedur II dipanggil oleh prosedur I.
sambil melewatkan nilai aktual sebuah argument (berupa informasi
[nama Excel User yg membuka file tsb] dan [tgl & jam saat itu]

- Prosedur 2, atas perintah dari prosedur 1 mencatat informasi tsb ke
sebuah file text (file terpisah / di luar workbook tsb) lalu mensave dan
menutupnya kembali.

Jadi apakah workbook disave-atau- tidak oleh pembukanya, informasi
selalu dicatat di LogBook tsb. 

Prosedur 2 (yg memiliki 1 argument) TIDAK harus dibuat sbg prosedur
Fungsi
walaupun harus mengandung Argument
(karena kalau hanya sekedar melewatkan argument antar prosedur,
atau prosedur yg memerlukan argument; prosedur yg dipanggil
TIDAK HARUS DITULIS SEBAGAI prosedur Fungsi, jangan ikut² salah kaprah !! )

Mudah-mudahan bermanfaat, dan tentu saja Anda dapat mengembangkan
sesuai keperluan anda.

-ctv-
19 Sept 2009





__._,_.___
+-:: XL-mania ::::::::::::::::::::----------------------------------+
| Tolong cariin momods kerjaan jadi direktur dongggg... :D :D :D    |
| http://www.facebook.com/group.php?gid=37671048001&ref=mf          |
+-------------------------------------------------------------------+
| DILARANG : MLM, money game, OOT, iklan tanpa izin, SARA, testing, |
| pembicaraan pribadi, one line message,  melecehkan,  tidak sopan. |
+-------------------------------------------------------------------+
| Buat subjek yang kreatif, jangan : "tanya", "help", "mohon bantu" |
| Usahakan besar attachment < 200 kb. Gunakan  winzip  jika  perlu. |
+-------------------------------------------------------------------+
| Ajak teman-teman Anda bergabung dengan mengirim e-mail kosong ke  |
| XL-mania-subscribe@yahoogroups.com atau kirimkan mereka file dari |
| http://groups.yahoo.com/group/XL-mania/files/Promotion/           |
+-------------------------------------------------------------------+
| Berikan testimoni di : http://www.friendster.com/xlmania atau...  |
| http://www.xl-mania.com/2008/06/testimoni-xl-mania.html           |
+-------------------------------------------------------------------+
| Message lama ada di :                                             |
| http://groups.yahoo.com/group/XL-mania/messages [perlu yahoo id]  |
| http://www.mail-archive.com/xl-mania@yahoogroups.com              |
+-------------------------------------------------------------------+
Recent Activity
Visit Your Group
Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Yahoo! Groups

Small Business Group

Ask questions,

share experiences

Yahoo! Groups

Cats Group

Join a group for

cat owners like you

.

__,_._,___

Nenhum comentário:

Arquivo do blog