Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1952to1956
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Batch Datei erstellen und beschreiben aus excel tabelle

Batch Datei erstellen und beschreiben aus excel tabelle
23.11.2023 12:20:02
Giuppy
Hallo,

ich möchte mehrere bat Datei mit vba in der Ordner C:\#KDFatture\MAIL_NEW\Batch erstellen
Die Daten sollen dinamisch aus Excel genommen werden.
Zuerst soll ein Bat Datei erstellen mit Name aus Excel Spalte E und den inhalt sollte für jede Datei angepasst werden

z.B.
Datei Name = SchoopCF.bat aus Spalte E
Inhalt

@@echo off && title %~n0 && color 70

for /f "delims=" %%i in (C:\#KDFatture\MAIL_NEW\Dateien\schoopDat.txt) do xcopy "C:\#KDFatture\Kunden\KopieCaopti06\%%i*.pdf" "C:\#KDFatture\MAIL_NEW\PDF\Schoop_PDF"



den Wert schoopDat.txt aus Excel Spalte A und der Wert Schoop_PDF soll aus die Tabelle Dat Spalte C

https://www.herber.de/bbs/user/164531.xlsx



Kann mir jemand helfen

Vielen Dank
Giuppy

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Batch Datei erstellen und beschreiben aus excel tabelle
23.11.2023 14:59:05
Uduuh
Hallo,
teste mal:
Sub BAT_erstellen()

Dim lRow As Long, S2 As String
Const strPath As String = " C:\#KDFatture\MAIL_NEW\Batch\"
Const txt1 As String = "@@echo off && title %~n0 && color 70"
Const txt2 As String = "for /f ""delims="" %%i in (C:\#KDFatture\MAIL_NEW\Dateien\#.txt) do xcopy ""C:\#KDFatture\Kunden\KopieCaopti06\%%i*.pdf"" ""C:\#KDFatture\MAIL_NEW\PDF\#_PDF"""
For lRow = 1 To Cells(Rows.Count, 1).End(xlUp).Row
S2 = Replace(txt2, "#.txt", Cells(lRow, 1))
S2 = Replace(S2, "#_PDF", Cells(lRow, 3))

Open strPath & Cells(lRow, 5) For Output As #1
Print #1, txt1
Print #1, S2
Close #1

Next lRow
End Sub

Gruß aus'm Pott
Udo
Anzeige
Batch Datei erstellen und beschreiben aus excel tabelle
24.11.2023 11:10:33
giuppy
Hallo Udo,
Vielen Dank
leider funktioniert nicht
bleibt hängen bei Open strPath & Cells(lRow, 5) For Output As #1
Was ist for Output As#1?

Es sollte zuerst ein bat datei erstellt und dann den text geschrieben sein

Const txt1 As String = "@@echo off && title %~n0 && color 70"
Const txt2 As String = "for /f ""delims="" %%i in (C:\#KDFatture\MAIL_NEW\Dateien\#.txt) do xcopy ""C:\#KDFatture\Kunden\KopieCaopti06\%%i*.pdf"" ""C:\#KDFatture\MAIL_NEW\PDF\#_PDF"""

Viele Grüße
Giuppy
AW: Batch Datei erstellen und beschreiben aus excel tabelle
24.11.2023 22:45:23
Uduuh
Hallo,
versuchs mal ohne das Leerzeichen vor C:\
Const strPath As String = "C:\#KDFatture\MAIL_NEW\Batch\"

Gruß aus'm Pott
Udo
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige