Kapalı Dosyaya Kayıt

askm

Destek Ekibi
Destek Ekibi
Katılım
4 Haziran 2005
Mesajlar
2,745
Excel Vers. ve Dili
2010-2016
Kolay gelsin.
Kapalı dosyaya kayıt yapmak istiyorum. Yalnız dosya cvs uzantılı. Benim istediğim exceldeki gibi Deneme xlsm Sayfa1 deki A1 den başlayıp C 21 e kadar olan verileri Kayıt-1.cvs deki Kayıt - 1 sayfasına A1-C21 arasına kaydetmek. Ado ile de denedim. Dosya aç kaydet ile de denedim olmadı.

Aşağıdaki örneklerden yardım almaya çalıştım ama yapamadım.
Kod:
Sub Emre()
    Dim con As Object, rs As Object
    Dim sorgu As String
    Set con = CreateObject("adodb.connection")
    Set rs = CreateObject("adodb.recordset")
        con.Open "provider=microsoft.ace.oledb.12.0;data source=" & ThisWorkbook.Path & _
        "\CoA&MSDS&PDF.xls;extended properties=""excel 8.0;hdr=no"""
        sorgu = "Select F1 FROM [Etken$]"
        rs.Open sorgu, con, 1, 3
        rs.Addnew
        rs.Fields(0) = "azra"
        rs.Update
        rs.Close: con.Close
    sorgu = vbNullString: Set rs = Nothing: Set con = Nothing
End Sub
Kod:
Private Sub CommandButton1_Click()
Dim i As Byte, sat As Long, wb As Workbook, sh As Worksheet
Application.DisplayAlerts = False
If Workbooks.Open(ThisWorkbook.Path & "\İHTİYAÇ LİSTESİ.xls").ReadOnly = True Then
    ActiveWorkbook.Close
End If
Application.DisplayAlerts = True
Set sh = Workbooks("İHTİYAÇ LİSTESİ.xls").Sheets("Sayfa1")
sat = sh.Cells(65536, "A").End(xlUp).Row + 1
If sat + 15 >= 65533 Then
    MsgBox "Buradaki verileri sayfa alamaz." & vbLf & "Satır doldu.Kaytılar girilmedi", vbCritical, "UYARI"
    Workbooks("İHTİYAÇ LİSTESİ.xls").Close
    Exit Sub
End If
For i = 1 To 15
    If Me.Controls("adet" & Format(i, "00")) <> "" Then
        sh.Cells(sat, "A").Value = sat - 2
        sh.Cells(sat, "B").Value = CDbl(Me.Controls("adet" & Format(i, "00")).Text)
        sh.Cells(sat, "B").NumberFormat = "#,##0.00"
        sh.Cells(sat, "C").Value = CDbl(Me.Controls("sayi" & Format(i, "00")).Text)
        sh.Cells(sat, "C").NumberFormat = "#,##0.00"
        sh.Cells(sat, "D").Value = Me.Controls("malz" & Format(i, "00")).Text
        
        Me.Controls("adet" & Format(i, "00")).Text = ""
        Me.Controls("sayi" & Format(i, "00")).Text = ""
        Me.Controls("malz" & Format(i, "00")).Text = ""
        sat = sat + 1
    End If
Next i
Workbooks("İHTİYAÇ LİSTESİ.xls").Close True
MsgBox "Kayıtlar başarı ile girildi." & vbLf & _
"evrengizlen@hotmail.com", vbOKOnly + vbInformation, "E V R E N"

End Sub
 
Üst