ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 1727|回复: 3

新手求助帖……

[复制链接]

TA的精华主题

TA的得分主题

发表于 2014-3-21 19:58 | 显示全部楼层 |阅读模式
Sub 授权使用(ByRef flag As Integer)

    Dim Usernames(100) As String
    Dim Computernames(100) As String

    Dim username1 As String
    Dim computername1 As String

    Dim i, regFlag As Integer

    Dim PresentDay, LastDate As Long

    Dim theNum1, theNum2 As Integer

    Dim Hidename As String

    Hidename = "000O0000O00000OOOOOOOOO00OOOOOO"


    Usernames(1) = "P121060"

    Usernames(2) = "P148183"
    Usernames(3) = "P145018"
    Usernames(4) = "P145020"
    Usernames(5) = "P145021"

    Usernames(6) = "P136382"
    Usernames(7) = "P136450"
    Usernames(8) = "P136458"
    Usernames(9) = "P136642"
    Usernames(10) = "P136662"

    Usernames(11) = "P129162"
    Usernames(12) = "P129175"
    Usernames(13) = "P129196"
    Usernames(14) = "P129198"

    Usernames(15) = "P120746"
    Usernames(16) = "P120856"
    Usernames(17) = "P120862"
    Usernames(18) = "P120955"
    Usernames(19) = "P120824"
    Usernames(20) = "P121031"
    Usernames(21) = "P121032"
    Usernames(22) = "P121033"
    Usernames(23) = "P120828"
    Usernames(24) = "P120937"
    Usernames(25) = "P120938"
    Usernames(26) = "P120717"
    Usernames(27) = "P120718"

    Usernames(28) = "P208430"
    Usernames(29) = "P208449"
    Usernames(30) = "P208646"
    Usernames(31) = "P208445"
    Usernames(32) = "P208652"

    Usernames(33) = "P153868"
    Usernames(34) = "P153864"
    Usernames(35) = "P153862"
    Usernames(36) = "P153867"
    Usernames(37) = "P153863"
    Usernames(38) = "P153866"
    Usernames(39) = "P153869"
    Usernames(40) = "P153870"
    Usernames(41) = "P153940"
    Usernames(42) = "Administrator; "
    Usernames(43) = "Administrator"

    username1 = UCase(VBA.Environ("username"))
    computername1 = UCase(VBA.Environ("computername"))

    flag = 0
    i = 1
    Do While i < 100
        If username1 = Usernames(i) Then

                flag = 1
                Exit Do

        End If
        i = i + 1
    Loop


    If flag = 1 Then
        regFlag = GetSetting("Superwid", "identity", "regFlag", 2)
        If regFlag = 2 Then
            SaveSetting "Superwid", "identity", "regFlag", 1
        End If
    End If



    If flag = 0 Then
        SaveSetting "Superwid", "identity", "regFlag", 0
    End If


    PresentDay = Date
    If PresentDay >= 41913 Then
        flag = 0
        SaveSetting "Superwid", "identity", "regFlag", 0
        Sheets(Hidename).Visible = xlSheetVisible
        Sheets(Hidename).Select
        Range("IP3687").Value = 0
        Sheets(Hidename).Visible = xlSheetVeryHidden

    End If

    Sheets(Hidename).Visible = xlSheetVisible
    Sheets(Hidename).Select

    theNum1 = Range("IP3687").Value
    Range("IP23687").Value = Range("IP23687").Value + 1
    theNum2 = Range("IP23687").Value

    LastDate = Range("BS12345").Value
    Range("BS12345").Value = Date

    Sheets(Hidename).Visible = xlSheetVeryHidden

    If theNum1 = 0 Then
        flag = 0
        SaveSetting "Superwid", "identity", "regFlag", 0
    End If

    If theNum2 > 2500 Then
        flag = 0
        SaveSetting "Superwid", "identity", "regFlag", 0
    End If

    If PresentDay < LastDate Then
        flag = 0

        SaveSetting "Superwid", "identity", "regFlag", 0

        Sheets(Hidename).Visible = xlSheetVisible
        Sheets(Hidename).Select
        Range("BS12345").Value = LastDate
        Sheets(Hidename).Visible = xlSheetVeryHidden

    End If


    regFlag = GetSetting("Superwid", "identity", "regFlag", 2)
    If regFlag = 0 Then
        flag = 0
    End If


    If username1 = "P121060" Then
        flag = 1
    End If


End Sub

这段程序明明是限制授权人的,我知道能看懂上面,但是到了下面我就看不懂了,而且我把我的用户名添加到上面的用户列表中也没有用,请各位大神帮我看看……



该贴已经同步到 78舵主87的微博

TA的精华主题

TA的得分主题

 楼主| 发表于 2014-3-22 23:34 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
难道看都没人看么?新手求助呀……

TA的精华主题

TA的得分主题

发表于 2014-3-25 15:44 | 显示全部楼层

TA的精华主题

TA的得分主题

发表于 2014-4-3 16:37 | 显示全部楼层
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-11-26 00:51 , Processed in 0.030231 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表