Enregistrer feuille & renommer si existe

Bonjour,

Je persiste avec un nouveau fichier pour Excel Mac 2011.

Définir les constantes STR_FOLDER et FILE_EXTENSION.

A tester !...

Cdlt.

Public Sub CopySheetInNewWorkbook()
Dim wb As Workbook
Dim wbPath As String
Dim wbFullName As String, wbFullName2 As String
Dim wbName As String, wbName2 As String, wbName3 As String
Dim Indx As Long
Const STR_FOLDER As String = "/users/jean-eric/downloads/dossiers/"   'a definir
Const FILE_EXTENSION As String = ".xlsm" 'a definir

    If IsMac = False Then
        MsgBox "Cette procedure est prevue pour Excel Mac !...", 64, "Information"
        Exit Sub
    End If

    Set wb = ThisWorkbook
    wbFullName = wb.FullName
    wbPath = wb.Path & Application.PathSeparator
    wbName = wb.Name
    wbName2 = VBA.Mid$(wbName, 1, VBA.InStrRev(wbName, ".") - 1)

    If VBA.InStr(wbName2, "_") > 0 Then
    Indx = VBA.Split(wbName2, "_")(1)
        Indx = Indx + 1
    Else
        Indx = 1
    End If

    wbName3 = VBA.Split(wbName2, "_")(0) & "_" & Indx

    If FileOrFolderExistsOnMac(STR_FOLDER) = False Then
        MakeFolderIfNotExist (STR_FOLDER)
    End If

    wbFullName2 = STR_FOLDER & wbName3 & FILE_EXTENSION

    MacGetSaveAsFilenameExcel MyInitialFilename:=wbFullName2, FileExtension:=FILE_EXTENSION

    'Informations : Afficher la fenetre Execution au prealable
    Debug.Print wbFullName
    Debug.Print wbPath
    Debug.Print wbName
    Debug.Print wbName2
    Debug.Print Indx
    Debug.Print wbName3
    Debug.Print wbFullName2

End Sub
Rechercher des sujets similaires à "enregistrer feuille renommer existe"