본문 바로가기
  • 환영 합니다 ! Welcome!
VBA For Creo

CREO 파일 타입 알아보기

by ToolBOX01 2021. 2. 18.
반응형

open된 파일의 타입을 알아보는 프로그램 입니다.  리턴 값이 "0" 이면 Assemble, "1" 이면 Part 입니다.

 

 

Sub Run()
        Dim asynconn As New pfcls.CCpfcAsyncConnection
        Dim conn As pfcls.IpfcAsyncConnection
        Dim session As pfcls.IpfcBaseSession
    
    On Error GoTo RunError
        Set conn = asynconn.Connect("", "", ".", 5)
        Set session = conn.session
    
        Dim model As IpfcModel
        Set model = session.CurrentModel
        Dim Modeltype As Integer
        Modeltype = model.Type

        If Modeltype = 0 Then
             Cells(5, 6) = "ASM"
          ElseIf Modeltype = 1 Then
             Cells(5, 7) = "PART"
          Else
             Cells(5, 8) = "확인 하십시오"
        End If
            
        Cells(5, 5) = model.Type       
    conn.Disconnect (2)

RunError:
    
    If Err.Number <> 0 Then
        MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
                "Error No: " + CStr(Err.Number) + Chr(13) + _
                "Error: " + Err.Description, vbCritical, "Error"
    
        If Not conn Is Nothing Then
            If conn.IsRunning Then
                conn.Disconnect (2)
            End If
        End If
    End If

End Sub

 

 

비즈니스 문의 : lionkk@idt21c.com