J'ai une déclaration Si comme suit:IF Déclaration en VBA
If Weekday(Worksheets("Actual").Range("C1").Value) = vbSunday Then
Qu'est-ce que cette déclaration Si le fait est de créer 3 e-mails avec des pièces jointes et des liens de données du samedi et vendredi, pour envoyer si la date est entrée dans la feuille de travail est un dimanche. Si la date du dimanche est la première d'un mois (c.-à-d. 1er août 2010), le samedi (31 juillet 2010) et le vendredi (30 juillet 2010), l'état If ne reconnaît pas la variation mensuelle et est donc incapable de créer 3 emails avec les pièces jointes et les liens nécessaires. Comment puis-je créer/modifier mon instruction If de sorte que lorsque le 1er jour d'un nouveau mois tombe un dimanche ou un lundi et que je doive extraire les données du mois précédent, il reconnaît le changement du mois et crée les pièces jointes correctes et des liens ??
Voici le code complet je pour créer l'e-mail ...
Private Sub sendemail(esubj)
Sheets("Actual").Select
myfridate = Cells(1, 3).Value
myfridate = DateAdd("d", -2, myfdate)
myfridate = Format(myfridate, "mm-dd-yy")
Sheets("Actual").Select
mysatdate = Cells(1, 3).Value
mysatdate = DateAdd("d", -1, myfdate)
mysatdate = Format(mysatdate, "mm-dd-yy")
If Weekday(Worksheets("Actual").Range("C1").Value) = vbSunday Then
Set omail = CreateItem(olMailItem)
ROW_BEGIN = 1
ROW_END = 72
Sheet1.Activate
Range("I7").Select
fileSat = "\\firework\public\FINANCE\Daily Report\FY10\Key Indicator\"
fileSat = fileSat & Left(Range("I7"), 3) & Right(Year(Date), 2)
fileSat = fileSat & "\Key Indicator Daily Report - " & mysatdate & ".xls"
Sheet1.Activate
Range("I7").Select
fileSun = "\\firework\public\FINANCE\Daily Report\FY10\Key Indicator\"
fileSun = fileSun & Left(Range("I7"), 3) & Right(Year(Date), 2)
fileSun = fileSun & "\Key Indicator Daily Report - " & mysundate & ".xls"
Sheet1.Activate
Range("I7").Select
fileFri = "\\firework\public\FINANCE\Daily Report\FY10\Key Indicator\"
fileFri = fileFri & Left(Range("I7"), 3) & Right(Year(Date), 2)
fileFri = fileFri & "\Key Indicator Daily Report - " & myfridate & ".xls"
With omail
.Subject = "M Key Indicator Daily Report"
.BodyFormat = olFormatHTML
.HTMLBody = "<a href ='" & fileFri & "'>Key Indicator Daily Report - " & myfridate & "</a><br><a href ='" & fileSat & "'>Key Indicator Daily Report - " & mysatdate & "</a><br><a href ='" & fileSun & "'>Key Indicator Daily Report - " & mysundate & "</a>"
.To = "me.com"
.Display
End With
Set omail1 = CreateItem(olMailItem)
With omail1
.Subject = "R Key Indicator Daily Report"
.BodyFormat = olFormatHTML
.To = "you.com"
.Attachments.Add fileFri
.Attachments.Add fileSat
.Attachments.Add fileSun
.Display
End With
Set omail2 = CreateItem(olMailItem)
With omail2
.Subject = "K Key Indicator Daily Report"
.BodyFormat = olFormatHTML
.To = "them.com"
.Attachments.Add fileFri
.Attachments.Add fileSat
.Attachments.Add fileSun
.Display
End With
ElseIf Weekday(Worksheets("Actual").Range("C1").Value) = vbFriday Or _
Weekday(Worksheets("Actual").Range("C1").Value) = vbSaturday Then
Else
ROW_BEGIN = 1
ROW_END = 72
Sheet1.Activate
Range("I7").Select
fileSun = "\\firework\public\FINANCE\Daily Report\FY10\Key Indicator\"
fileSun = fileSun & Left(Range("I7"), 3) & Right(Year(Date), 2)
fileSun = fileSun & "\Key Indicator Daily Report - " & mysundate & ".xls"
Set omail = CreateItem(olMailItem)
With omail
.Subject = "M Key Indicator Daily Report"
.BodyFormat = olFormatHTML
.HTMLBody = "<a href ='" & fileSun & "'>Key Indicator Daily Report - " & mysundate & "</a>"
.To = "me.com"
.Display
End With
Set omail1 = CreateItem(olMailItem)
With omail1
.Subject = "R Key Indicator Daily Report"
.BodyFormat = olFormatHTML
.To = "you.com"
.Attachments.Add fileSun
.Display
End With
Set omail2 = CreateItem(olMailItem)
With omail2
.Subject = "K Key Indicator Daily Report"
.BodyFormat = olFormatHTML
.To = "them.com"
.Attachments.Add fileSun
.Display
End With
End If
'ActiveWorkbook.Close
Set omail = Nothing
End Sub
@ Thomas, merci pour votre aide. Mais l'extension du fichier est ce qui finit par me gâcher. "I7" est une cellule de mon classeur qui a "AOUT". Donc, mon fichier ext est en train de lire \\ firework \ public \ FINANCE \ Rapport quotidien \ FY10 \ Indicateur clé \ AUG10 \ Rapport d'indicateurs clés - 07 \ 30 \ 2010. Quand AUG10 devrait effectivement être JUL10, avec le changement de date. – Edmond