Sauvegarde format texte DOS
bonjour a tous,
j'enregistre une macro pour sauvegarder au format texte DOS (.txt)
Code:
1 2 3 4 5 6 7 8 9
|
Sub Macro2()
'
' Macro2 Macro
'
Range("A10").Select
ActiveWorkbook.SaveAs Filename:="C:\Users\moi\Documents\Classeur1.txt", _
FileFormat:=xlTextMSDOS, CreateBackup:=False
End Sub |
ce code marche bien mais il s'applique au classeur actif. donc pas de souci.
je develloppe une macro qui me permet d'ouvrir la boite de dialogue et souhaite integrer ce "fileformat" mais je ne sais pas ou.
voici mon code initial
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
Function save_as_perso(plage)
Dim fnam, x&
'fname = Application.GetSaveAsFilename("fichier " & Format(Date, "dd mm yyyy") & Format(Date, " yyyy-mm-dd"), "(*.txt), *.txt", , "Sauvegarde monfichier")
fname = Application.GetSaveAsFilename(InitialFileName:=Environ("userprofile") & "\Desktop", FileFormat:=xlTextMSDOS, CreateBackup:=False, filefilter:="fichier Text (*.txt),*.txt", title:="ENREGISTREMENT FICHIER TEXT")
If fname <> False Then
plage.Copy
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}"): .GetFromClipboard: texte = .GetText(1): End With
x = FreeFile: Open fname For Output As #x: Print #x, texte: Close #x
With Application: .CutCopyMode = False: .CutCopyMode = True: End With
End If
End Function |
Ma question est : pourriez vous me dire a quel endroit je doit inserer le "fileformat" dans ce code?
merci par avance pour votre aide.