Bonjour,
je cherche à supprimer un fichier par l'intermédiaire de vba. Est-ce possible sans utiliser la fonction kill (qui ne marche pas sous mac os)?
Merci, Xavier
Bonjour,
je cherche à supprimer un fichier par l'intermédiaire de vba. Est-ce possible sans utiliser la fonction kill (qui ne marche pas sous mac os)?
Merci, Xavier
Salut, voir VBA code in Excel 2011 for the Mac càd
Use VBA Kill to delete files
Note: In computers running Windows, you can use the VBA Kill command to delete files from your system.
However, on a Mac, the Kill command will not work correctly with long file names (max of 32 with the extension).
The following code demonstrates a work around for this.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 Sub KillFile() 'Call the KillFileOnMac function to delete the file from a Mac. KillFileOnMac "Macintosh HD:Users:YourUserName:Documents:YourFileName.xlsx" End Sub Function KillFileOnMac(Filestr As String) 'Ron de Bruin '30-July-2012 'Delete files from a Mac. 'Uses AppleScript to avoid the problem with long file names Dim ScriptToKillFile As String ScriptToKillFile = "tell application " & Chr(34) & _ "Finder" & Chr(34) & Chr(13) ScriptToKillFile = ScriptToKillFile & _ "do shell script ""rm "" & quoted form of posix path of " & _ Chr(34) & Filestr & Chr(34) & Chr(13) ScriptToKillFile = ScriptToKillFile & "end tell" On Error Resume Next MacScript (ScriptToKillFile) On Error GoTo 0 End Function
Et ben ça marche nickel mr kiki29! Merci encore
Partager