본문 바로가기
  • Welcome!
VBA For Creo

drw에서 sheet 개수 알아보고, sheet 선택 하기

by ToolBOX01 2021. 2. 12.
반응형

drw에서 sheet 개수를 파악 하고, sheet를 선택 하는 프로그램 

 


Sub sheet_number()

    Dim asynconn As New pfcls.CCpfcAsyncConnection
    Dim conn As pfcls.IpfcAsyncConnection
    Set conn = asynconn.connect("", "", ".", 5)
    Dim oSession As IpfcBaseSession
    Set oSession = conn.Session
    Dim oModel As IpfcModel
    Set oModel = oSession.CurrentModel
    
    Dim oSheetOwner As IpfcSheetOwner
    Set oSheetOwner = oModel
    
    ' drw 파일이 가지고 있는 전체 Sheet수량 표시
    Dim oSheetallNumber As Long
    oSheetallNumber = oSheetOwner.NumberOfSheets
   
    ' Sheet 선택
    oSheetOwner.CurrentSheetNumber = 3
      
    'Disconnect with Creo
    conn.Disconnect (2)
    
    'Cleanup
    Set asynconn = Nothing
    Set conn = Nothing
    Set Session = Nothing
    Set oModel = Nothing
    
End Sub