Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1296to1300
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

Excel als Text speichern

Excel als Text speichern
28.01.2013 13:37:24
Uwe
Hallo,
in folgendem Makro wird die Mappe als TXT gespeichert, allerdings möchte ich die Abfrage wohin die Datei gespeichert wird umgehen und diese immer auf Laufwerk d:\ abspeichern. Wie müsste das Makro geändert werden?
Danke,
Uwe
Sub Text_File_erstellen()
Dim wks As Worksheet
Dim varFile As Variant
Dim strText As String
Dim Zeile As Long, FF As Integer
varFile = Application.GetSaveAsFilename(InitialFileName:="Text.txt", _
Filefilter:="Textfiles (*.txt), *.txt", _
Title:="Bitte Namen der Textdatei wählen/eingeben")
If varFile = False Then Exit Sub
FF = FreeFile()
Set wks = ActiveSheet
Open varFile For Output As #FF
With wks
For Zeile = 1 To .Cells(.Rows.Count, 1).End(xlUp).Row
strText = "[" & .Cells(Zeile, 1).Text & "];[" _
& .Cells(Zeile, 2).Text & "]_[" _
& .Cells(Zeile, 3).Text & "]_[" _
& .Cells(Zeile, 4).Text & "]"
Print #FF, strText
Next Zeile
End With
Close #FF
Set wks = Nothing
End Sub

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Excel als Text speichern
28.01.2013 14:11:45
haw
Hallo Uwe,
so z.B.:
Sub Text_File_erstellen()
Dim wks As Worksheet
Dim varFile As Variant
Dim strText As String
Dim Zeile As Long, FF As Integer
'  varFile = Application.GetSaveAsFilename(InitialFileName:="Text.txt", _
'    Filefilter:="Textfiles (*.txt), *.txt", _
'    Title:="Bitte Namen der Textdatei wählen/eingeben")
varFile = "D:\test.txt"
If varFile = False Then Exit Sub
FF = FreeFile()
Set wks = ActiveSheet
Open varFile For Output As #FF
With wks
For Zeile = 1 To .Cells(.Rows.Count, 1).End(xlUp).Row
strText = "[" & .Cells(Zeile, 1).Text & "];[" _
& .Cells(Zeile, 2).Text & "]_[" _
& .Cells(Zeile, 3).Text & "]_[" _
& .Cells(Zeile, 4).Text & "]"
Print #FF, strText
Next Zeile
End With
Close #FF
Set wks = Nothing
End Sub
Gruß
Heinz

Anzeige
AW: Excel als Text speichern
28.01.2013 14:13:08
haw
Hallo Uwe,
so z.B.:
Sub Text_File_erstellen()
Dim wks As Worksheet
Dim varFile As Variant
Dim strText As String
Dim Zeile As Long, FF As Integer
'  varFile = Application.GetSaveAsFilename(InitialFileName:="Text.txt", _
'    Filefilter:="Textfiles (*.txt), *.txt", _
'    Title:="Bitte Namen der Textdatei wählen/eingeben")
varFile = "D:\test.txt"
If varFile = False Then Exit Sub
FF = FreeFile()
Set wks = ActiveSheet
Open varFile For Output As #FF
With wks
For Zeile = 1 To .Cells(.Rows.Count, 1).End(xlUp).Row
strText = "[" & .Cells(Zeile, 1).Text & "];[" _
& .Cells(Zeile, 2).Text & "]_[" _
& .Cells(Zeile, 3).Text & "]_[" _
& .Cells(Zeile, 4).Text & "]"
Print #FF, strText
Next Zeile
End With
Close #FF
Set wks = Nothing
End Sub

Gruß
Heinz

Anzeige
AW: Excel als Text speichern
28.01.2013 15:31:51
Uwe
Hallo Heinz,
funktioniert leider nicht. Die Textdatei soll ohne Benutzereingriff automatisch gespeichert werden.
Gruss,
Uwe

AW: Excel als Text speichern
29.01.2013 06:34:38
haw
Hallo Uwe,
ich vermute, du hast die ursprünglichen drei Zeilen nicht auskommentiert.
Dann muss es funktionieren.
Natürlich musst du den Dateinamen (text.txt) an deine Wünsche anpassen.
Gruß
Heinz

AW: Excel als Text speichern
29.01.2013 08:08:45
Uwe
Hallo Heinz,
war wohl ein typisches Montagsproblem, ich habe versehentlich eine Zeile zu viel auskommentiert.
Danke!
Uwe

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige