Excel-MAC : Enregistrer en pdf

Thoms29 Messages postés 4 Statut Membre -  
Thoms29 Messages postés 4 Statut Membre -
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 !!

1 réponse

  1. Thoms29 Messages postés 4 Statut Membre
     
    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