yeni oluştuluran txt'yi listboxta göster, dosya yolunu tazele

Katılım
5 Mart 2010
Mesajlar
295
Excel Vers. ve Dili
Microsoft Office 2010
Altın Üyelik Bitiş Tarihi
20.12.2018
Kod:
Private Sub CommandButton6_Click() 'YENİ TXT OLUŞTUR BUTONU
TextBox5.Value = ""

adres = ThisWorkbook.Path & "\"
dosyaadı = InputBox("Lütfen dosya adı giriniz..")
 Open adres & dosyaadı & ".TXT" For Output As #1
    Print #1, TextBox5.Value
 Close

End Sub
ekteki çalışmamda yeni txt oluştur butonuna tıkladığımda yukarıdaki kod devreye giriyor.. ve inputbox içine girilen isimde txt metin belgesi açıyor, textbox5 içindeki veriyi oluşturulan metin belgesi içine kaydedip kapatıyor..

sorunum şu;

1-inputbox içine veri girilmediği zaman txt metin belgesi oluşturmasın.. uyarı versin

2- diyelim ki bir txt dosyası oluşturduk. oluşturduğumuz yeni txt belgesi listbox1'de listelensin..

yardımlarınızı rica ediyorum.
 

Ekli dosyalar

Emir Hüseyin Çoban

Destek Ekibi
Destek Ekibi
Katılım
11 Ağustos 2008
Mesajlar
5,891
Excel Vers. ve Dili
Office 2013 Tr - Win10 x64
. . .

Kod:
Private Sub CommandButton6_Click() 'YENİ TXT OLUŞTUR BUTONU
    TextBox5.Value = ""
    
    adres = ThisWorkbook.Path & "\"
    dosyaadı = InputBox("Lütfen dosya adı giriniz..")
    If dosyaadı = "" Then
        MsgBox "Dosya Adı Girmediniz!..", vbCritical
        Exit Sub
    End If
    
    Open adres & dosyaadı & ".TXT" For Output As #1
    Print #1, TextBox5.Value
    Close
    
    s1 = ListBox1.ListCount
    s2=sheets("VERİ").cells(rows.count,"A").end(3).row+1
    ListBox1.AddItem
    ListBox1.List(s1, 0) = adres & dosyaadı & ".TXT"
    ListBox1.List(s1, 1) = dosyaadı & ".TXT"
    sheets("VERİ").cells(s2,"A")=adres & dosyaadı & ".TXT"
    sheets("VERİ").cells(s2,"B")=dosyaadı & ".TXT"

End Sub
. . .
 
Üst