HY
I Have a little problem with using excel object with Catia
I think this could be a vba problem. It looks like this:
I open a workbook with vba, then take some data from the workbook and use the data later in catia. But when im trying to use some excel object function like countA or range the vba editor prompts me with this error:
Method 'Range' of object '_Global' faild
This happends only with the first start of the makro, after the first start every thing with it is ok.
And the second thing is how can i trow the excel objcet out of memory, it always stays one in the system
This is the code form my sub
Public Sub mit()
'On Error Resume Next
Dim path As String
'Dim mith(), ohneh() As String
Dim ilew As Integer
Dim i As Integer
Dim area As Range
Dim mith() As String
'Static ohneh() As String
Dim objExcel As excel.Application
Dim objWorkbook As Workbook
path = "Z:\data\INTERNES\zk_zeichnungen\LC"
Set objExcel = CreateObject("Excel.Application"): objExcel.Visible = False
objExcel.SheetsInNewWorkbook = 1
Set objWorkbook = objExcel.Workbooks.Open(Filename:=path & "\materials.xls")
ilew = objExcel.WorksheetFunction.CountA(Range("A:A"))
ReDim mith(ilew - 2)
For i = 1 To (ilew - 1)
Set area = objWorkbook.Sheets(1).Range("A1").Offset((ilew - ilew) + i)
mith(i - 1) = area.Value
Next i
'objExcel.Visible = True 'pokazujemy okno Excela
'objWorkbook.save
'zwolnienei pami?ci zaj?tej przez zmienne obiektowe
mater.List = mith()
objWorkbook.Close
Set objExcel = Nothing
Set objWorkbook = Nothing
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP