Comment enregistrer un fichier extrait en PDF ou on veut
J
Bonjour à tous,
J'ai une macro qui envoi un PDF en piece jointe mais ca m'enregistre le PDF dans un endroit que je ne choisi pas.
Est-il possible de choisir l'endroit ?
Sub relance_frns()
For Each sh In Worksheets
Select Case sh.Name
Case "Macro", "Qualite", "extrait", "Supplier index", "PVI", "courrier"
Case Else
sh.Activate
ActiveSheet.Copy
Range("T:T").EntireColumn.Hidden = True
ActiveSheet.SaveAs Filename:="C:\Users\cccuia\Documents\Relance\" & Range("D2").Value
'Il faut activer la référence "Microsoft Outlook Library" Avant de lancer cette macro,
' Dans l'éditeur VBA: Faire Menu / Tools / Reference / Cocher "Microsoft Outlook Library"
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim CurFile As String
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
CurFile = ThisWorkbook.Path & "\" & Range("D2") & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=CurFile, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
With olMail
.To = Range("T2")
'.CC = ""
.Subject = "sujet"
.Body = Workbooks("PVI").Sheets("courrier").Range("A1")
.Attachments.Add CurFile
.Display
'.Send
End With
' Effacer les variables objets
Set olMail = Nothing
Set olApp = Nothing
ActiveWorkbook.Close
Kill "C:\Users\cccuia\Documents\Relance\*.xls"
End Select
Next
End SubJawst
J
Il suffit de remplacer la ligne par ca:
CurFile = "C:\Users\cccuia\Documents\Relance\" & Range("D2").Value & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=CurFile, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
OpenAfterPublish:=False