XL 2016 question

farchirel

XLDnaute Nouveau
Bonjour, je voudrais d'après un fichier source (Feuil 2) une fois rempli manuellement, pouvoir enregistrer une copie à un endroit dans mon ordinateur avec le nom d'une cellule(b6) + date.
par la suite créer une copie en pdf sous le même nom et enfin l'envoyer par outlook grâce à un bouton .

Merci de votre aide!

Franck
 

Pièces jointes

  • 0_RAPPORT DE CONTROLE V23.xlsm
    30.9 KB · Affichages: 14
Solution
Bonjour,

Comme ceci dans ce cas.


VB:
Option Explicit

Sub sauver()
Application.ScreenUpdating = False
ActiveSheet.Copy
ChDir "C:\Excel"
Application.Dialogs(xlDialogSaveAs).Show Range("B6") & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date)
Application.ScreenUpdating = True
PDF
End Sub

Sub PDF()
Application.ScreenUpdating = False
ActiveSheet.Copy
ChDir "C:\PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Range("B6").Value & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date) & ".pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    From:=1, To:=1, OpenAfterPublish:=False
Application.ScreenUpdating = True
SendWithAtt
End Sub

Sub SendWithAtt()
' Macro BrunoM45...

Fipat

XLDnaute Occasionnel
Bonjour,

Pour enregistrer à un endroit désiré et en même temps créer le fichier PDF.

VB:
Sub sauver()
Application.ScreenUpdating = False
ActiveSheet.Copy
ChDir "C:\Excel"
Application.Dialogs(xlDialogSaveAs).Show Range("B6") & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Range("B6").Value & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date) & ".pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    From:=1, To:=1, OpenAfterPublish:=False
Application.ScreenUpdating = True
End Sub

Pour la messagerie peut-être voir ici
https://www.excel-downloads.com/threads/envoyer-mail-feuille-en-pdf-par-messagerie-defaut.20003296/
 
Dernière édition:

Fipat

XLDnaute Occasionnel
Bonjour,

Comme ceci dans ce cas.


VB:
Option Explicit

Sub sauver()
Application.ScreenUpdating = False
ActiveSheet.Copy
ChDir "C:\Excel"
Application.Dialogs(xlDialogSaveAs).Show Range("B6") & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date)
Application.ScreenUpdating = True
PDF
End Sub

Sub PDF()
Application.ScreenUpdating = False
ActiveSheet.Copy
ChDir "C:\PDF"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
Range("B6").Value & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date) & ".pdf", Quality:= _
    xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    From:=1, To:=1, OpenAfterPublish:=False
Application.ScreenUpdating = True
SendWithAtt
End Sub

Sub SendWithAtt()
' Macro BrunoM45 modifié pour le chemin
' Nécessite la référence : Microsoft Outlook 1x Object Library
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurFile As String
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

'La macro va récupérer le PDF par rapport à la date
CurFile = "C:\PDF" & "\" & Range("B6").Value & " - " & Day(Date) & "-" & Month(Date) & "-" & Year(Date) & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=CurFile, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
With olMail
.To = "xxx@gmail.com"
.CC = "name2@domain2.com"
.Subject = "Main courante Flashover"
.Body = "Vous trouverez ci-joint le fichier PDF ..."
.Attachments.Add CurFile
'.Attachments.Add "c:\My Documents\book.doc"
.Display '.Send
End With
MsgBox "Merci de vérifier que le message apparait dans -messages envoyés- dans votre messagerie OUTLOOK."

' Effacer les variables objets
Set olMail = Nothing
Set olApp = Nothing
End Sub
 

Staple1600

XLDnaute Barbatruc
Bonsoir le fil

merci FIPAT pour la macroi et aussi pour le conseil!! :)
Tout fonctionne c'est top!
=>farchirel
Bonjour le fil

[Pour infos]
Si j'étais moi, j'éviterai de diffuser ma vraie adresse mail sur un forum
Sans doute, un oubli
Ou alors c'est une invitation pour recevoir tout plein de spams ;)
(cf message#4: farchirel@tezor.fr ;))
Euh, le conseil initial, c'était le mien, non ?
Transparence quand tu nous tiens!
:rolleyes:
 

Discussions similaires

Réponses
2
Affichages
138
Réponses
7
Affichages
262

Statistiques des forums

Discussions
314 053
Messages
2 105 101
Membres
109 264
dernier inscrit
lejulpat