×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Catia to Excel File by Macro (Failure)

Catia to Excel File by Macro (Failure)

Catia to Excel File by Macro (Failure)

(OP)
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

RE: Catia to Excel File by Macro (Failure)

(OP)
I solve this question myself.I guess I am wrong while defined excel documentation."Dim workbooks As Workbooks" is changed "Dim workbooks" then solved it.
Thank you.

RE: Catia to Excel File by Macro (Failure)

In VBA, Open Tools / References and make sure you have Microsoft Excel xx Object Library selected:

xx depends on your excel version, for Excel 2010, I have 14.0


Eric N.
indocti discant et ament meminisse periti

RE: Catia to Excel File by Macro (Failure)

(OP)
I understood clearly but I am working on .Catvba is it same?Because I saw your Location: c:\program Files(x86)\Microsoft Office\office14\EXCEL.EXE

RE: Catia to Excel File by Macro (Failure)

(OP)
first of all I am glad your help,thank both of you.It works correctly.And also I have another question if it is ok I will give a link here you are.If it is not problem can you look at this? Thanks a lot.

http://www.eng-tips.com/viewthread.cfm?qid=350505

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close