Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

[Excel] computer name

[es] :: Office :: Excel :: [Excel] computer name

[ Pregleda: 1558 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Sudarica

Član broj: 119175
Poruke: 209
93.159.68.*



Profil

icon [Excel] computer name01.11.2009. u 16:15 - pre 176 meseci
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
 
Odgovor na temu

Ivek33

Član broj: 66174
Poruke: 2898



+66 Profil

icon Re: [Excel] computer name01.11.2009. u 18:50 - pre 176 meseci
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 
 
Odgovor na temu

3okc
Χoᴘᴦoѡ

Moderator
Član broj: 811
Poruke: 1319

Jabber: 3okc@elitesecurity.org


+116 Profil

icon Re: [Excel] computer name01.11.2009. u 20:45 - pre 176 meseci
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

Have you found helpful examples, solutions or ideas-in-work, please consider the
following:
• Citation of *actual page* you are going to using is welcome.
• Have you saw "Value Added" examples you are going to incorporate to your
profitable blog, daily job or any money making venture: How about online donation?
↗Ana & Vlade Divac Foundation
Hvala!
 
Odgovor na temu

Sudarica

Član broj: 119175
Poruke: 209
87.252.140.*



Profil

icon Re: [Excel] computer name02.11.2009. u 13:35 - pre 176 meseci
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
 
Odgovor na temu

[es] :: Office :: Excel :: [Excel] computer name

[ Pregleda: 1558 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.