2,462
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Function GetMyEmailRowNum() As Integer
Dim objOutlook As Object
Set objOutlook = CreateObject("outlook.application")
Dim objNS As Object
Set objNS = objOutlook.getnamespace("mapi")
Dim strEmail As String
strEmail = objNS.CurrentUser.Address
Dim i As Integer
For i = 8 To 14 Step 3
If Cells(i, 3) = strEmail Then
GetMyEmailRowNum = i
Exit Function
End If
Next
GetMyEmailRowNum = 0
End Function
Sub approve_Click()
Dim intRow As Integer
intRow = GetMyEmailRowNum()
If intRow = 0 Then
MsgBox "审批失败: 您的邮件地址不在列表中!", vbExclamation
Else
Cells(intRow, 5) = "Approve"
End If
End Sub
Sub reject_Click()
Dim intRow As Integer
intRow = GetMyEmailRowNum()
If intRow = 0 Then
MsgBox "审批失败: 您的邮件地址不在列表中!", vbExclamation
Else
Cells(intRow, 5) = "Reject"
End If
End Sub
Option Explicit
Private fso As New FileSystemObject
Private mblnSaving As Boolean
Private mstrEmail As String
Public mintRow As Integer
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Me.Saved Or SaveAsUI Or mblnSaving Then
Exit Sub
End If
If Not IsNumeric(Range("B5")) Then
Range("B5") = "001"
Else
Range("B5") = Format(Range("B5") + 1, "000")
End If
Dim strOldPath As String
strOldPath = Me.FullName
Dim strDir As String
strDir = fso.GetParentFolderName(strOldPath)
Dim strNewName As String
strNewName = Range("B5") & ".xlsm"
Dim strNewPath As String
strNewPath = fso.BuildPath(strDir, strNewName)
mblnSaving = True
Me.SaveAs strNewPath
fso.DeleteFile strOldPath, True
mblnSaving = False
Cancel = True
End Sub
Private Sub Workbook_Open()
mblnSaving = False
Do
mstrEmail = InputBox("输入你的E-MAIL:")
If mstrEmail = "" Then
mintRow = 0
Exit Do
End If
Dim i As Integer
For i = 1 To 10
If StrComp(Cells(i, 7), mstrEmail, vbTextCompare) = 0 Then
mintRow = i
Exit Do
End If
Next
MsgBox "您的Email不在邮件列表中!", vbExclamation
Loop
End Sub
Option Explicit
Sub approve_Click()
Range("B2") = "approve"
If ThisWorkbook.mintRow > 0 Then
Cells(ThisWorkbook.mintRow, 7).Font.Color = vbBlack
End If
End Sub
Sub reject_Click()
Range("B2") = "reject"
If ThisWorkbook.mintRow > 0 Then
Cells(ThisWorkbook.mintRow, 7).Font.Color = vbBlack
End If
End Sub