Bonjour
alors voila mon pb, j'ai crée une macro pour envoyer des mails automatiques (en cliquant sur un bouton qd même 🙄 ) depuis excel mais mon pb est que cette macro ne fonctionne que sur mon compte du boulot pour toutes les autres personnes elle ne fonctionne pas
voici le code :
Sub Mail_ENVOI_PI()
'Working in 2000-2010
Application.ScreenUpdating = False
ActiveWorkbook.Save
Dim Source As Range
Dim Dest As Workbook
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim I As Long
'demande numero de produits isolés
numero = InputBox(PROMPT:="Numéro", Title:="Numéro du produits isolés")
Sheets("Mes").Activate
Range("f4").Select
Selection.Value = numero
Set Source = Nothing
On Error Resume Next
Set Source = Worksheets("Mes").Range("A1:b35").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, " & _
"please correct and try again.", vbOKOnly
Exit Sub
End If
Application.EnableEvents = False
Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)
Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With
TempFilePath = Environ$("temp") & "\"
TempFileName = numero & "_11_12"
If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007-2010
FileExtStr = ".xls": FileFormatNum = 56
End If
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
'For I = 1 To 3
.SendMail Recipients:="truc @tartanpion.com", _
Subject:="DEMANDE D'ISOLEMENT PRODUIT FINI (" & numero & "_11/12)"
' If Err.Number = 0 Then Exit For
' Next I
On Error GoTo 0
.Close SaveChanges:=False
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Sheets("base de données").Activate
End Sub
Je ne pense pas que celà vienne de la macro mais si vous avez une idée, je vous en remercie d'avance
bonne journée
alors voila mon pb, j'ai crée une macro pour envoyer des mails automatiques (en cliquant sur un bouton qd même 🙄 ) depuis excel mais mon pb est que cette macro ne fonctionne que sur mon compte du boulot pour toutes les autres personnes elle ne fonctionne pas
voici le code :
Sub Mail_ENVOI_PI()
'Working in 2000-2010
Application.ScreenUpdating = False
ActiveWorkbook.Save
Dim Source As Range
Dim Dest As Workbook
Dim wb As Workbook
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim I As Long
'demande numero de produits isolés
numero = InputBox(PROMPT:="Numéro", Title:="Numéro du produits isolés")
Sheets("Mes").Activate
Range("f4").Select
Selection.Value = numero
Set Source = Nothing
On Error Resume Next
Set Source = Worksheets("Mes").Range("A1:b35").SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Source Is Nothing Then
MsgBox "The source is not a range or the sheet is protected, " & _
"please correct and try again.", vbOKOnly
Exit Sub
End If
Application.EnableEvents = False
Set wb = ActiveWorkbook
Set Dest = Workbooks.Add(xlWBATWorksheet)
Source.Copy
With Dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
.Cells(1).PasteSpecial Paste:=xlPasteValues
.Cells(1).PasteSpecial Paste:=xlPasteFormats
.Cells(1).Select
Application.CutCopyMode = False
End With
TempFilePath = Environ$("temp") & "\"
TempFileName = numero & "_11_12"
If Val(Application.Version) < 12 Then
'You use Excel 2000-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007-2010
FileExtStr = ".xls": FileFormatNum = 56
End If
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
'For I = 1 To 3
.SendMail Recipients:="truc @tartanpion.com", _
Subject:="DEMANDE D'ISOLEMENT PRODUIT FINI (" & numero & "_11/12)"
' If Err.Number = 0 Then Exit For
' Next I
On Error GoTo 0
.Close SaveChanges:=False
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Sheets("base de données").Activate
End Sub
Je ne pense pas que celà vienne de la macro mais si vous avez une idée, je vous en remercie d'avance
bonne journée