Option Explicit
Function login() As String
login = Application.UserName
End Function
Private Sub Workbook_Open()
Dim Nom As String, Fonction As String, Tel As String, Fax As String, Mail As String, Offre, Version As String
Select Case login
Case "gilles"
Nom = "x"
Fonction = "x"
Tel = "x1"
Fax = "x"
Mail = "x"
Offre = Year(Date) & "-0000C/x"
Case "y"
Nom = "y"
Fonction = "y"
Tel = "y"
Fax = "y"
Mail = "y"
Offre = Year(Date) & "-0000C/y"
'etc autres cases supprimés dans cet exemple
Case Else
MsgBox "Login non répertorié"
End Select
Version = ThisWorkbook.CustomDocumentProperties("Version").Value
If Nom <> "" Then
'Dim x As Long
' For x = 1 To 3
Sheets("Offre").Select
'With Sheets(x)
Cells(1, 19).Value = Version
Cells(2, 4).Value = Offre
Cells(3, 4).Value = Date
Cells(8, 14).Value = Nom
Cells(9, 14).Value = Fonction
Cells(10, 14).Value = Tel
'.Cells(10, 3).Value = Fax
Cells(11, 14).Value = Mail
Cells(13, 14).Value = "Son NOM"
Cells(14, 14).Value = "Commercial"
Cells(15, 14).Value = "Son portable"
Cells(16, 14).Value = "Son mail"
'End With
'Next
End If
Sheets("Offre").Select
Range("C9").Select
'Ce qui suit efface toute la procédure événementielle "Workbook_Open"
Dim StartLine As Long, LineCount As Long
On Error Resume Next
If ThisWorkbook.Path = "" Then
If ThisWorkbook.VBProject.Protection Then Exit Sub
With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
StartLine = .ProcStartLine("Workbook_Open", 0)
If StartLine Then
LineCount = .ProcCountLines("Workbook_Open", 0)
.DeleteLines StartLine, LineCount
End If
End With
End If
ThisWorkbook.CustomDocumentProperties("Version").Value
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question