• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

excelden txt aktarırken dosya adı verme

Katılım
25 Aralık 2011
Mesajlar
28
Excel Vers. ve Dili
2007 tr
merhaba arkadaslar asagıdakı kod ile sayfa2 deki verileri txt dosyasına test.txt olarak kayıt ediyor ben bu txt dosyasına sayfa1 deki p1 hucresindeki degeri vermesini ve sonunda test.txt degilde yenı olusturdugu txt dosyasını actırmak istiyorum ne gibi bir degisiklik yapmam gerek kodlar da
Kod:
Sub Makro4()
Dim deg As String, i As Long, st As Long, j As Byte
st = Cells(Rows.Count, "A").End(xlUp).Row
Open (ThisWorkbook.Path & "\test.txt") For Output As #1
For i = 1 To st
    For j = 1 To 5
        deg = deg & " " & Cells(i, j)
    Next j
    deg = Right(deg, Len(deg) - 1)
    Print #1, deg
    deg = ""
Next i
Close #1
MsgBox "Not olusturuldu." & vbLf & ""
Shell "notepad.exe " & ActiveWorkbook.Path & "/test.txt"
End Sub
 
KOD

Rich (BB code):
Sub Makro4()
Dim deg As String, i As Long, st As Long, j As Byte


st = Cells(Rows.Count, "A").End(xlUp).Row

dosya = Worksheets("Sayfa1").Range("P1").Value
Open (ThisWorkbook.Path & "\" & dosya) For Output As #1
For i = 1 To st
    For j = 1 To 5
        deg = deg & " " & Cells(i, j)
    Next j
    deg = Right(deg, Len(deg) - 1)
    Print #1, deg
    deg = ""
Next i
Close #1
MsgBox "Not olusturuldu." & vbLf & ""
Shell "notepad.exe " & ActiveWorkbook.Path & "/" & dosya
End Sub
 
kodun uzantısını yazmayı unutmuşum
Rich (BB code):
Sub Makro4()
Dim deg As String, i As Long, st As Long, j As Byte


st = Cells(Rows.Count, "A").End(xlUp).Row

dosya = Worksheets("Sayfa1").Range("P1").Value & ".txt"
Open (ThisWorkbook.Path & "\" & dosya) For Output As #1
For i = 1 To st
    For j = 1 To 5
        deg = deg & " " & Cells(i, j)
    Next j
    deg = Right(deg, Len(deg) - 1)
    Print #1, deg
    deg = ""
Next i
Close #1
MsgBox "Not olusturuldu." & vbLf & ""
Shell "notepad.exe " & ActiveWorkbook.Path & "/" & dosya
End Sub
 
Teşekkürler iyi çalışmalar
 
Geri
Üst