Excel-MAC : Enregistrer en pdf

Fermé
Thoms29 Messages postés 3 Date d'inscription mercredi 3 juin 2015 Statut Membre Dernière intervention 4 juin 2015 - Modifié par Thoms29 le 3/06/2015 à 09:17
Thoms29 Messages postés 3 Date d'inscription mercredi 3 juin 2015 Statut Membre Dernière intervention 4 juin 2015 - 3 juin 2015 à 09:30
Bonjour,

Je suis nouveau en VBA et je cherche a creer une macro qui me permettrai d'enregistrer plusieurs onglets en PDF peu importe le systeme d'exploitation de l'ordinateur.
J'arrive a le faire pour Windows mais pas pour Mac...
Et les solutions que je trouve sur le net ne donne rien.

Quelqu'un pour m'aider ?!
Merci d'avance !!


A voir également:

1 réponse

Thoms29 Messages postés 3 Date d'inscription mercredi 3 juin 2015 Statut Membre Dernière intervention 4 juin 2015
3 juin 2015 à 09:30
Oui j'ai un logiciel pdf puisque je peux enregistrer ma feuille excel sous forme de PDF de maniere manuelle.

Mon code est le suivant, la partie pour Mac est dans le Else :

Sub PrintPDF2()
Dim wksSheet As Worksheet
Dim TheOS As String
Dim strPath As String
Dim myFile As Variant
Dim strFile As String

TheOS = Application.OperatingSystem

If InStr(1, TheOS, "Windows") > 0 Then

Set wksSheet = ActiveSheet

'enter name and select folder for file
' start in current workbook folder
strFile = Replace(Replace(wksSheet.Cells(1, 2).Value, " ", ""), ".", "_") _
& "_" _
& Format(Now(), "yyyymm") _
& ".pdf"
strFile = ThisWorkbook.Path & "\" & strFile

myFile = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")

If myFile <> "False" Then
ws.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=myFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False

MsgBox "PDF file has been created."
End If


exitHandler:
Exit Sub

Else
Set wksSheet = ActiveSheet
strFile = Replace(Replace(wksSheet.Cells(1, 2).Value, " ", ""), ".", "_") _
& "_" _
& Format(Now(), "yyyymm") _
& ".pdf"
strFile = ThisWorkbook.Path & ":" & strFile

myFile = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
Exit Sub
End If

End Sub
0