Effacer 1ère ligne fichier texte

kwakos

XLDnaute Occasionnel
Bonjour à tous, le forum

Est-il possible par une macro finement élaborée d'effacer la 1ère ligne d'un fichier texte (C:\mon dossier\fichier.txt) ?

J'ai lu sur différents fils la manière d'ouvrir par macro le bloc note, mais pas d'y supprimer des éléments ?


lmerci a tous
 

Minick

XLDnaute Impliqué
Re : Effacer 1ère ligne fichier texte

Salut,

Essai ca:
Code:
Sub DelLigne()
    Dim Ligne As String, FichierSource As String, FichierTmp As String
    Dim CptLigne As Long, LigneASupprimer As Long

    FichierSource = "c:\text.txt"
    FichierTmp = "c:\Tmp.Tmp"
    LigneASupprimer = 1
    
    Open FichierSource For Input As #1
        Open FichierTmp For Output As #2
            While Not EOF(1)
                CptLigne = CptLigne + 1
                Input #1, Ligne
                If CptLigne <> LigneASupprimer Then
                    Print #2, Ligne
                End If
            Wend
        Close #2
    Close #1
    Kill FichierSource
    Name FichierTmp As FichierSource
End Sub
++
Minick

EDIT : Salut tout le monde
 

Discussions similaires

Réponses
18
Affichages
755
Réponses
14
Affichages
659

Statistiques des forums

Discussions
312 492
Messages
2 088 902
Membres
103 982
dernier inscrit
krakencolas