- Katılım
- 15 Mart 2005
- Mesajlar
- 387
- Excel Vers. ve Dili
- Microsoft 2016 En 64 Bit
- Altın Üyelik Bitiş Tarihi
- 20-03-2024
Arkadaşlar merhaba,
Aşağıdaki prosudure'da bir excel dosyasından kapalı excel dosyasına veri aktarıyorum. Kapalı dosya kapanmış olmasına rağmen, Windows görev yöneticisinde 2 adet Excel uygulaması açık gözüküyor. Kapalı dosyaya ait dosyaya veri aktarırken açılan excel uygulamasını VBA'dan nasıl kaldırabilirim? (İşletim sistemin windows7)
Kolay gelsin.
---------------------------------------
Sub data_transfer()
Dim MyDB As DAO.Database
Dim RS As DAO.Recordset
Dim NewXL As Excel.Application
Dim DataWB As String
Dim Wb As Workbook
On Error GoTo ErrHandler:
DBpath = Application.ActiveWorkbook.FullName
Set MyDB = OpenDatabase(DBpath, False, False, "Excel 8.0")
Set RS = MyDB.OpenRecordset("SELECT * FROM [Liste$] ")
Set NewXL = New Excel.Application
NewXL.Visible = False
DataWB = ThisWorkbook.Path & Application.PathSeparator & "data.xls"
Set Wb = NewXL.Workbooks.Open(DataWB)
Set tbl = Wb.Sheets(1).Range("A1").CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count + 1, tbl.Columns.Count).ClearContents
Wb.Sheets(1).Range("A2").CopyFromRecordset RS
NewXL.Workbooks(Dir(DataWB)).Close SaveChanges:=True
Msg = MsgBox("Bilgiler data isimli Excel Kitabına Aktarılmıştır...", vbExclamation, "DİKKAT !")
RS.Close
MyDB.Close
Set RS = Nothing
Set MyDB = Nothing
Set Wb = Nothing
Set NewXL = Nothing
Exit Sub
ErrHandler:
If Err.Number <> 0 Then MsgBox Err.Description
End Sub
Aşağıdaki prosudure'da bir excel dosyasından kapalı excel dosyasına veri aktarıyorum. Kapalı dosya kapanmış olmasına rağmen, Windows görev yöneticisinde 2 adet Excel uygulaması açık gözüküyor. Kapalı dosyaya ait dosyaya veri aktarırken açılan excel uygulamasını VBA'dan nasıl kaldırabilirim? (İşletim sistemin windows7)
Kolay gelsin.
---------------------------------------
Sub data_transfer()
Dim MyDB As DAO.Database
Dim RS As DAO.Recordset
Dim NewXL As Excel.Application
Dim DataWB As String
Dim Wb As Workbook
On Error GoTo ErrHandler:
DBpath = Application.ActiveWorkbook.FullName
Set MyDB = OpenDatabase(DBpath, False, False, "Excel 8.0")
Set RS = MyDB.OpenRecordset("SELECT * FROM [Liste$] ")
Set NewXL = New Excel.Application
NewXL.Visible = False
DataWB = ThisWorkbook.Path & Application.PathSeparator & "data.xls"
Set Wb = NewXL.Workbooks.Open(DataWB)
Set tbl = Wb.Sheets(1).Range("A1").CurrentRegion
tbl.Offset(1, 0).Resize(tbl.Rows.Count + 1, tbl.Columns.Count).ClearContents
Wb.Sheets(1).Range("A2").CopyFromRecordset RS
NewXL.Workbooks(Dir(DataWB)).Close SaveChanges:=True
Msg = MsgBox("Bilgiler data isimli Excel Kitabına Aktarılmıştır...", vbExclamation, "DİKKAT !")
RS.Close
MyDB.Close
Set RS = Nothing
Set MyDB = Nothing
Set Wb = Nothing
Set NewXL = Nothing
Exit Sub
ErrHandler:
If Err.Number <> 0 Then MsgBox Err.Description
End Sub