The following is dealing with Active X and Excel. I know of only this forum for answers.
My Problem (today) :
I am sending Sketch numbers to Excel to be sorted and then Print the new sorted list.
I can open Excel and plug in my data just fine.
My problem occurs when I try to close the Instance of Excel I just opened. It won't.
I am doing the Ctrl+Alt+Delete and then Task Manager. Under "Processes" is where I can see my Excel.exe start up, do all the massaging, and then it just sits there......mocking me. I can seem to close it.
When I run the macro again...It finds the Instance open from the first try, does its thing. But still won't close. What Gives ??
ANY tips are appreciated
Thank you
Tim Livingston
Acad 2004 vb6
The following code is just a fragment but the Excel code is still here
Option Explicit
Public Sub CoilateTickets()
Dim MyExcel As Excel.Application
Dim MyExcelSheet As Excel.Worksheet
Dim MySS As AcadSelectionSet
Dim GrpC(0 To 1) As Integer
Dim GrpV(0 To 1) As Variant
GrpC(0) = 0: GrpV(0) = "Insert"
GrpC(1) = 2: GrpV(1) = "SPI-Tick*"
Set MySS = ThisDrawing.SelectionSets.Add("SKNumbers95")
MySS.Select acSelectionSetAll, , , GrpC, GrpV
'--------------------------------------------------------
'Go get Excel and open the worksheet
On Error Resume Next
Set MyExcel = GetObject(, "Excel.Application")
If Err <> 0 Then
Err.Clear
Set MyExcel = CreateObject("Excel.Application")
If Err <> 0 Then
MsgBox "Could Not Load Excel!", vbExclamation
End
End If
End If
On Error GoTo 0
MyExcel.Workbooks.Add ("I:\CADD\TIM\Auto-Excel Files\SkNumberer.xls")
MyExcel.Visible = True
MyExcel.Sheets("Sheet1").Select
Set MyExcelSheet = MyExcel.ActiveWorkbook.Sheets("Sheet1")
'------------------------------------------------------------------------------
'Populate the worksheet
'------------------------------------------------------------------------------------------
'Sort the column
'------------------------------------------------------------------------------------------
'Print the tickets
'------------------------------------------------------------------------------------------
' Close up Shop
MySS.Delete
MyExcel.DisplayAlerts = False
MyExcel.ActiveWindow.Close False
MyExcel.DisplayAlerts = True
MyExcel.Quit
If Not MyExcel Is Nothing Then
Set MyExcelSheet = Nothing
Set MyExcel = Nothing
End If
End Sub


Reply With Quote
