[ Sudarica @ 01.11.2009. 16:15 ] @
| pomoć
u jednoj radnoj knjizi radi više korisnika. Prilikom kreiranja podataka u svakom redu u određenom stupcu bi trebalo biti upisano prilikom pospremanja s čijeg je kompjutera kreiran podatak odnosno computer name (npr pperic)
Primjer:
datm; vrsta; račun; tko je to upisao (computer name)
isti korisnik može kreirati više redova par puta u toku dana, tjedna ili mjeseca
Pozdrav
|
[ Ivek33 @ 01.11.2009. 18:50 ] @
na ovom linku
http://www.mrexcel.com/forum/showthread.php?t=46889
sam našao ovo ( možda pomogne ;)
Code:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error GoTo carryon
Application.ScreenUpdating = False
Dim lpBuff As String * 25
Dim ret As Long, UserName As String
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
Sheets("log").Activate
lastrow = [a1].CurrentRegion.Rows.Count
'add username date and time
Sheets("log").Cells(lastrow + 1, 1).Value = Application.UserName
Sheets("log").Cells(lastrow + 1, 2).Value = Date
Sheets("log").Cells(lastrow + 1, 2).NumberFormat = "mmmm d, yyyy"
Sheets("log").Cells(lastrow + 1, 3).Value = Time
Sheets("log").Cells(lastrow + 1, 4).Value = UserName
Application.ScreenUpdating = True
ActiveWorkbook.Saved = True
carryon:
End Sub
[ 3okc @ 01.11.2009. 20:45 ] @
Dobićeš podatak od Environ() funkcije (inače, pominjano već u
aplikacija za fiskalnu kasu).
Biće jasnije kada pokreneš primer
Code:
Sub Environment()
Debug.Print Environ("computername")
Debug.Print Environ("username")
End Sub
Ili, preko sledećeg primera pogledaj sve raspoložive vrednosti
Code:
Sub EnvironmentList()
Dim EnvString As String
Dim Indx As Byte
Do
Indx = Indx + 1
EnvString = Environ(Indx)
Debug.Print Indx, EnvString
Loop Until EnvString = ""
End Sub
[ Sudarica @ 02.11.2009. 13:35 ] @
upravo ono što mi treba mi je code od Ivek33
ukopirala sam code u VBAproject (ThisWorkbook) u zajedničku radnu knjigu, u Sheet1, kojeg sam nazvala "log"
Code:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
On Error GoTo carryon
Application.ScreenUpdating = False
Dim lpBuff As String * 25
Dim ret As Long, UserName As String
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
Sheets("log").Activate
lastrow = [a1].CurrentRegion.Rows.Count
'add username date and time
Sheets("log").Cells(lastrow + 1, 1).Value = Application.UserName
Sheets("log").Cells(lastrow + 1, 2).Value = Date
Sheets("log").Cells(lastrow + 1, 2).NumberFormat = "mmmm d, yyyy"
Sheets("log").Cells(lastrow + 1, 3).Value = Time
Sheets("log").Cells(lastrow + 1, 4).Value = UserName
Application.ScreenUpdating = True
ActiveWorkbook.Saved = True
carryon:
End Sub
i sve radi savršeno
Hvala Iveku33 i 3okc
Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.