suleymanyaman
Industrial
- Jul 30, 2013
- 29
Hi Dear Friends,
I create a catia macro for "product" and I want to export from catia to excel. However it gives failure in Dim workbooks As workbooks Dim workbook As workbook compile failure is"User-defined type not defined" codes in below.Thank you.
Sub MatrixPrint(ByVal sName, ByVal matrix)
Dim subString As String
Dim Excel As Object
Dim workbooks As workbooks
Dim workbook As workbook
Dim Sheets As Object
Dim Sheet As Object
Dim worksheet As Excel.worksheet
Dim myworkbook As Excel.workbook
Dim myworksheet As Excel.worksheet
Set workbooks = Excel.Application.workbooks
Set myworkbook = Excel.workbooks.Add
Set myworksheet = Excel.ActiveWorkbook.Add
Set myworksheet = Excel.Sheets.Add
On Error Resume Next
Set Excel = GetObject(, "EXCEL.Application")
If Err.Number <> 0 Then
Err.Clear
Set Excel = CreateObject("EXCEL.Application")
Else
Err.Clear
MsgBox "Please note you have to close Excel", vbCritical
Exit Sub
End If
Dim a(11)
Dim i As Integer
For i = 0 To 11
If ((matrix(i) < 0.001) And (matrix(i) > -0.001)) Then
a(i) = 0#
Else
a(i) = matrix(i)
End If
Next
sTemp = sName + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
'count = 0
count = count + 1
subString = Right(sName, 4)
If subString = "IF.1" Then
MsgBox sName
Excel.Cells(2, count) = sName
Excel.Cells(2, count + 1) = CStr(a(9))
Excel.Cells(2, count + 2) = CStr(a(10))
Excel.Cells(2, count + 3) = CStr(a(11))
If strsearch = sName Then
sTemp = sName + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
Excel.Cells(1, 1) = sName
Excel.Cells(1, 2) = CStr(a(9))
Excel.Cells(1, 3) = CStr(a(10))
Excel.Cells(1, 4) = CStr(a(11))
MsgBox sTemp
End If
End If
End Sub
I create a catia macro for "product" and I want to export from catia to excel. However it gives failure in Dim workbooks As workbooks Dim workbook As workbook compile failure is"User-defined type not defined" codes in below.Thank you.
Sub MatrixPrint(ByVal sName, ByVal matrix)
Dim subString As String
Dim Excel As Object
Dim workbooks As workbooks
Dim workbook As workbook
Dim Sheets As Object
Dim Sheet As Object
Dim worksheet As Excel.worksheet
Dim myworkbook As Excel.workbook
Dim myworksheet As Excel.worksheet
Set workbooks = Excel.Application.workbooks
Set myworkbook = Excel.workbooks.Add
Set myworksheet = Excel.ActiveWorkbook.Add
Set myworksheet = Excel.Sheets.Add
On Error Resume Next
Set Excel = GetObject(, "EXCEL.Application")
If Err.Number <> 0 Then
Err.Clear
Set Excel = CreateObject("EXCEL.Application")
Else
Err.Clear
MsgBox "Please note you have to close Excel", vbCritical
Exit Sub
End If
Dim a(11)
Dim i As Integer
For i = 0 To 11
If ((matrix(i) < 0.001) And (matrix(i) > -0.001)) Then
a(i) = 0#
Else
a(i) = matrix(i)
End If
Next
sTemp = sName + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
'count = 0
count = count + 1
subString = Right(sName, 4)
If subString = "IF.1" Then
MsgBox sName
Excel.Cells(2, count) = sName
Excel.Cells(2, count + 1) = CStr(a(9))
Excel.Cells(2, count + 2) = CStr(a(10))
Excel.Cells(2, count + 3) = CStr(a(11))
If strsearch = sName Then
sTemp = sName + " = " + CStr(a(9)) + ", " + CStr(a(10)) + ", " + CStr(a(11))
Excel.Cells(1, 1) = sName
Excel.Cells(1, 2) = CStr(a(9))
Excel.Cells(1, 3) = CStr(a(10))
Excel.Cells(1, 4) = CStr(a(11))
MsgBox sTemp
End If
End If
End Sub