PDA

View Full Version : ??? CreateObject("Inventor.ApprenticeServerComponent") ???



bweir
2005-07-18, 07:59 PM
How can I use the CREATEOBJECT function to access the Inventor.ApprenticeServerComponent. Here is my sample code (see below). I'd like to replace...
Dim oApp As New Inventor.ApprenticeServerCompoent
with a Set oApp = CreateObject("?????") but I don't know the string to use. Can somebody help me?

<---Code Begin--->

Sub GetDescrtiptions()

Dim sValue As String
Dim sPath As String
Dim sFile As String

Dim oDoc As ApprenticeServerDocument
Dim oApp As New Inventor.ApprenticeServerComponent

Dim oRange As Range

sPath = "c:\parts\"

Set oRange = Application.Selection

For i = 2 To oRange.Count
sValue = oRange.Item(i)

sFile = sPath & sValue

Set oDoc = oApp.Open(sFile)

oRange.Item(i).Offset(0, 1).Value = oDoc.PropertySets.Item(3).Item(14).Value
Next
End Sub

<---Code End--->

PS I'm using this in Excel.

chatcher
2005-07-19, 11:58 AM
You don't need CreateObject to access ApprenticeServer.

The problem with your code is the binding method you chose.

Try this instead:

Dim oApp as ApprenticeServerComponent

and then in a sub or function:

Set oApp = New ApprenticeServerComponent

You can then open a document for manipulation.

bweir
2005-07-19, 04:45 PM
Thanks for the tip. I would still like to know what string to use in order to use the CreateObject function. I'd like to trap an error at this point if Inventor & its components are not installed on the computer that the macro is being used on.

I don't want to add the files to the referances list in the VBA editor.

chatcher
2005-07-19, 08:39 PM
You could try:
CreateObject("Inventor.ApprenticeServer")

bweir
2005-07-19, 09:00 PM
Thanks, extactly what I needed =)