سلام دوستان در پرسشی دیگر من این راه حل خوب رو از استاد Dolfin یاد گرفتم . حالا می خوام این دستور رو جوری تغییر بدم که وابسته به شماره Sheet ها نباشه و کلا هرچی تو فایل هست رو شامل شود .
یه سوال دیگه هم دارم با توجه به این که این کد نویسی مخصوص ویندوز 64 بیتی است اگر کسی با ویندوز 32 بیتی این فایل رو اجرا کند احتمالا جواب میدهد یا نه ؟؟ اگر نمی دهد چه کار میشود کرد ؟
کد PHP:
Option Explicit
Declare PtrSafe Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long
Const NoError = 0 'The Function call was successful
Public Function GetUserName() As String
' Buffer size for the return string.
Const lpnLength As Integer = 255
' Get return buffer space.
Dim status As Integer
' For getting user information.
Dim lpName, lpUserName As String
' Assign the buffer size constant to lpUserName.
lpUserName = Space$(lpnLength + 1)
' Get the log-on name of the person using product.
status = WNetGetUser(lpName, lpUserName, lpnLength)
' See whether error occurred.
If status = NoError Then
' This line removes the null character. Strings in C are null-
' terminated. Strings in Visual Basic are not null-terminated.
' The null character must be removed from the C strings to be used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
' An error occurred.
GetUserName = "Unable to get the name."
GoTo lbl_Exit
End If
' Display the name of the person logged on to the machine.
GetUserName = lpUserName
lbl_Exit:
Exit Function
End Function
کد PHP:
Private Sub Workbook_Open()
If GetUserName = "s.tabibi" Or GetUserName = "a.alijanzadeh" Then
Sheet2.Unprotect ("132025")
Sheet3.Unprotect ("132025")
Else
Sheet2.Protect Contents:=True, Scenarios:=True, Password:=132025, AllowSorting:=True, AllowFiltering:=True
Sheet3.Protect Contents:=True, Scenarios:=True, Password:=132025, AllowSorting:=True, AllowFiltering:=True
End If
End Sub
دسترسی محدود با استفاده از Usename های لوگین شده در ویندوز (محدود از نظر تغییر دادن ولی قابل فیلتر و سورت کردن می باشد)
یوزر های وارد شده بالا یوزر هایی هستن که دسترسی کامل دارند .
|
اخطار: این یک موضوع قدیمی است به دلیل قدیمی بودن موضوع، ممکن است برخی فایل های ضمیمه به درستی کار نکنند. لطفا در صورت عدم ضرورت، از بالا آوردن موضوعات قدیمی خودداری نمایید. |
|
علاقه مندی ها (Bookmarks)