Bismark
08-14-2006, 06:29 AM
Hi!
I've have recently faced a problem with RANGE.
I have a macro in mdb-file, which opens an existing excel workbook. Then it merges two cells and makes the workbook visible. However when i am closing opened workbook by myself, process "EXCEL.EXE" remains intact in the list of process and continuies its work. It causes future problems. The code is presented below:
Public Sub PROBLEM_WITH_RANGE()
Dim objXLS As Excel.Application
Dim currWB As Excel.Workbook
Dim pathdir as String
pathdir="C:\work.xls"
Set dbPay = Application.CurrentDb
Set objXLS = New Excel.Application
Set currWB = objXLS.Workbooks.Open(pathdir, 0)
...........................
ActiveSheet.Range(ActiveSheet.Cells(2, 5), ActiveSheet.Cells(2, 6)).Select
Selection.Merge
...........................
currWB.Save
objXLS.Visible = True
Set currWB = Nothing
Set objXLS = Nothing
End Sub
You see, it is no good if you substitute merge-method by justify-methor or any other. But if you remove the code with "RANGE" the workbook will fully be closed by my mouse click. Moreover I know that all variables should be disosed to close "EXCEL.EXE" process, thus the question in my opinion shoud be:
HOW CAN I DISPOSE "RANGE"?
I'll be very glad if you help me to find a key for this problem door.
I've have recently faced a problem with RANGE.
I have a macro in mdb-file, which opens an existing excel workbook. Then it merges two cells and makes the workbook visible. However when i am closing opened workbook by myself, process "EXCEL.EXE" remains intact in the list of process and continuies its work. It causes future problems. The code is presented below:
Public Sub PROBLEM_WITH_RANGE()
Dim objXLS As Excel.Application
Dim currWB As Excel.Workbook
Dim pathdir as String
pathdir="C:\work.xls"
Set dbPay = Application.CurrentDb
Set objXLS = New Excel.Application
Set currWB = objXLS.Workbooks.Open(pathdir, 0)
...........................
ActiveSheet.Range(ActiveSheet.Cells(2, 5), ActiveSheet.Cells(2, 6)).Select
Selection.Merge
...........................
currWB.Save
objXLS.Visible = True
Set currWB = Nothing
Set objXLS = Nothing
End Sub
You see, it is no good if you substitute merge-method by justify-methor or any other. But if you remove the code with "RANGE" the workbook will fully be closed by my mouse click. Moreover I know that all variables should be disosed to close "EXCEL.EXE" process, thus the question in my opinion shoud be:
HOW CAN I DISPOSE "RANGE"?
I'll be very glad if you help me to find a key for this problem door.