Microsoft 365 Aide adaptation d'une macro

netparty

XLDnaute Occasionnel
Bonjour à tous
Je cherche à modifier la macro suivante :
VB:
Sub EXPORT_SCR()
    Dim Fichier$
    Dim Chemin$
    'Fichier = Worksheets("Calques").Range("C2") & ".scr"
    Fichier = "Calques.scr"
    Chemin = "c:\AUTOCAD_SCR"
  Dim dlig&, lig&, s$
  dlig = Cells(Rows.Count, 1).End(xlUp).Row 'cellule de comptage
  'Open ThisWorkbook.Path & "\RESULTAT.scr" For Output As #1
  Open Chemin & "\" & Fichier For Output As #1
  For lig = 7 To dlig 'ligne debut export
    s = Cells(lig, 8) ' colone a exporter
   ' If s <> "" Then
      'If lig <> dlig Then s = s & ","
      Print #1, s ';
   ' End If
  Next lig
  Close #1 ': MsgBox "Exportation effectuée.", 64, "Export"  '64 = icone "export" teste barre
End Sub

Cette macro me sert à exporter dans un fichier texte le contenu d'une colonne ligne par ligne, mais je voudrais ajouter entre chaque ligne exportée un texte identique qui est "Calque exporté" mais je ne sais comment l’insérer dans la boucle.

Merci d'avance et bonne journée
 

Laurent78

XLDnaute Occasionnel
Bonjour,

Ajouter après le Print #1, s
Print #1, "Calque exporté"


VB:
Sub EXPORT_SCR()
    Dim Fichier$
    Dim Chemin$
    'Fichier = Worksheets("Calques").Range("C2") & ".scr"
    Fichier = "Calques.scr"
    Chemin = "c:\AUTOCAD_SCR"
  Dim dlig&, lig&, s$
  dlig = Cells(Rows.Count, 1).End(xlUp).Row 'cellule de comptage
  'Open ThisWorkbook.Path & "\RESULTAT.scr" For Output As #1
  Open Chemin & "\" & Fichier For Output As #1
  For lig = 7 To dlig 'ligne debut export
    s = Cells(lig, 8) ' colone a exporter
   ' If s <> "" Then
      'If lig <> dlig Then s = s & ","
      Print #1, s ';
      Print#1, "Calque exporté"  ' à ajouter
   ' End If
  Next lig
  Close #1 ': MsgBox "Exportation effectuée.", 64, "Export"  '64 = icone "export" teste barre
End Sub


Bon dimanche
 

netparty

XLDnaute Occasionnel
Bonjour,

Ajouter après le Print #1, s
Print #1, "Calque exporté"


VB:
Sub EXPORT_SCR()
    Dim Fichier$
    Dim Chemin$
    'Fichier = Worksheets("Calques").Range("C2") & ".scr"
    Fichier = "Calques.scr"
    Chemin = "c:\AUTOCAD_SCR"
  Dim dlig&, lig&, s$
  dlig = Cells(Rows.Count, 1).End(xlUp).Row 'cellule de comptage
  'Open ThisWorkbook.Path & "\RESULTAT.scr" For Output As #1
  Open Chemin & "\" & Fichier For Output As #1
  For lig = 7 To dlig 'ligne debut export
    s = Cells(lig, 8) ' colone a exporter
   ' If s <> "" Then
      'If lig <> dlig Then s = s & ","
      Print #1, s ';
      Print#1, "Calque exporté"  ' à ajouter
   ' End If
  Next lig
  Close #1 ': MsgBox "Exportation effectuée.", 64, "Export"  '64 = icone "export" teste barre
End Sub


Bon dimanche
Merci beaucoup
 

Discussions similaires

Statistiques des forums

Discussions
312 242
Messages
2 086 532
Membres
103 243
dernier inscrit
SAH