S
surotkin
Hello everyone,
I found that I can not unload Excel (I open Excel-instance from Access
using objExcel.Quit method after I execute Copy method of Range object.
There is part of my code (without error handler block) which copie
cells from one worksheet, creates a new worksheet and pastes thos
cells with transpose option:
Public Function myTest2() As Long
Dim objExcel As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim ws_source As Excel.Worksheet
myTest2 = 0
Set objExcel = New Excel.Application
objExcel.Workbooks.Open FileName:="D:\test.xls"
Set wb = objExcel.Workbooks("test.xls")
Set ws_source = wb.Worksheets(1)
ws_source.Range(Cells(1, 1), Cells(10, 20)).*Copy*
wb.Sheets.Add
Set ws = wb.ActiveSheet
ws.Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone
SkipBlanks:=False, Transpose:=True
objExcel.CutCopyMode = False
wb.Close SaveChanges:=True
objExcel.*Quit*
Set ws = Nothing
Set ws_source = Nothing
Set wb = Nothing
Set objExcel = Nothing
End Function
Does anybody have an idea why?
Thanks.
surotki
I found that I can not unload Excel (I open Excel-instance from Access
using objExcel.Quit method after I execute Copy method of Range object.
There is part of my code (without error handler block) which copie
cells from one worksheet, creates a new worksheet and pastes thos
cells with transpose option:
Public Function myTest2() As Long
Dim objExcel As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim ws_source As Excel.Worksheet
myTest2 = 0
Set objExcel = New Excel.Application
objExcel.Workbooks.Open FileName:="D:\test.xls"
Set wb = objExcel.Workbooks("test.xls")
Set ws_source = wb.Worksheets(1)
ws_source.Range(Cells(1, 1), Cells(10, 20)).*Copy*
wb.Sheets.Add
Set ws = wb.ActiveSheet
ws.Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone
SkipBlanks:=False, Transpose:=True
objExcel.CutCopyMode = False
wb.Close SaveChanges:=True
objExcel.*Quit*
Set ws = Nothing
Set ws_source = Nothing
Set wb = Nothing
Set objExcel = Nothing
End Function
Does anybody have an idea why?
Thanks.
surotki