Skip to main content
12-Amethyst
August 24, 2023
Question

EXCEL VAB

  • August 24, 2023
  • 0 replies
  • 639 views

- Displays the name of the currently active model
- If no model is active, a VBA error message is displayed
- I don't know if the drawing name can be displayed? test it out ^_^

Sub Model_Nanme()

      Dim asynconn As New pfcls.CCpfcAsyncConnection
      Dim conn As pfcls.IpfcAsyncConnection
      Dim session As pfcls.IpfcBaseSession
      Dim Model As pfcls.IpfcModel

      Set conn = asynconn.Connect("", "", ".", 5)
      Set session = conn.session
      Set Model = session.CurrentModel

      Call MsgBox(Model.Filename)

'// Disconnect with Creo
conn.Disconnect (2)

'// Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set Model = Nothing

End Sub