Bonjour,
J'ai une macro qui lorsque l'on appuie sur un bouton crée un mail et joint le classeur en cours à ce mail tout marche parfaitement sous Excel 2007 mais pas sous Excel 2003 (message d'erreur "Run-time '1004' method Saveas a échoué..."), pouvez vous m'aider à résoudre ce problème ? Voici la macro:
Private Sub commandButton1_Click()
Dim Destwb As Workbook
Set Destwb = ActiveWorkbook
Dim TempFilePath, TempFileName, FileExtStr, FileFormatNum As String
TempFilePath = 51
FileExtStr = ".xls"
FileFormatNum = 56
' Saves the new workbook and then mail it.
TempFilePath = "c:\temp\" & Format(Now, "yyyymmdd") & "\"
If Dir(TempFilePath, vbDirectory) = "" Then
MkDir TempFilePath
End If
TempFileName = "_test_"
With Destwb
.SaveAs Filename:=TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
For i = 1 To 3
.SendMail "XXX@XXX.com", _
Cells(8, 3) & " - Test"
If Err.Number = 0 Then Exit For
Next i
On Error GoTo 0
.Close SaveChanges:=False
End With
End Sub
Merci !
J'ai une macro qui lorsque l'on appuie sur un bouton crée un mail et joint le classeur en cours à ce mail tout marche parfaitement sous Excel 2007 mais pas sous Excel 2003 (message d'erreur "Run-time '1004' method Saveas a échoué..."), pouvez vous m'aider à résoudre ce problème ? Voici la macro:
Private Sub commandButton1_Click()
Dim Destwb As Workbook
Set Destwb = ActiveWorkbook
Dim TempFilePath, TempFileName, FileExtStr, FileFormatNum As String
TempFilePath = 51
FileExtStr = ".xls"
FileFormatNum = 56
' Saves the new workbook and then mail it.
TempFilePath = "c:\temp\" & Format(Now, "yyyymmdd") & "\"
If Dir(TempFilePath, vbDirectory) = "" Then
MkDir TempFilePath
End If
TempFileName = "_test_"
With Destwb
.SaveAs Filename:=TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
On Error Resume Next
For i = 1 To 3
.SendMail "XXX@XXX.com", _
Cells(8, 3) & " - Test"
If Err.Number = 0 Then Exit For
Next i
On Error GoTo 0
.Close SaveChanges:=False
End With
End Sub
Merci !