Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Type Mismatch in Inventor7 with VB code

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
282 Views, 3 Replies

Type Mismatch in Inventor7 with VB code

Why when I try to open a part document with VB id doesn't work? I obtained a
VB error 13 Type Mismatch

Dim oApp As Inventor.Application
Set oApp = GetObject(, "Inventor.Application")

Dim oDoc As Inventor.PartDocument
Set oDoc = oApp.Documents.Open("c:\mypart.ipt")

If I try the same code from VBA it works fine:

Dim oDoc As Inventor.PartDocument
Set oDoc = ThisApplication.Documents.Open("c:\mypart.ipt")
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

I don't think an external VB app is able to determine the document type
before it's opened. Try changing the line to Dim oDoc as Inventor.Document.

I haven't tried this so I'm not sure if that's the answer or not (I don't
have VB).

"Alessio" wrote in message
news:8E58247214C25F6D2877D3C77A866694@in.WebX.maYIadrTaRb...
> Why when I try to open a part document with VB id doesn't work? I obtained
a
> VB error 13 Type Mismatch
>
> Dim oApp As Inventor.Application
> Set oApp = GetObject(, "Inventor.Application")
>
> Dim oDoc As Inventor.PartDocument
> Set oDoc = oApp.Documents.Open("c:\mypart.ipt")
>
> If I try the same code from VBA it works fine:
>
> Dim oDoc As Inventor.PartDocument
> Set oDoc = ThisApplication.Documents.Open("c:\mypart.ipt")
>
>
>
Message 3 of 4
Anonymous
in reply to: Anonymous

Thanks, but it doesn't work

I have made an other test and in fact I'm not able to link to the Documents
collection:

1. I open Inventor
2. I open some part file (one.ipt, two.ipt)
3. I run this code:

Dim oApp As Inventor.Application
Set oApp = GetObject(, "Inventor.Application")

Dim oDocs as Inventor.Documents
Set oDocs = oApp.Documents

4. I inspect the oApp variable (with VB WATCH) and I open in the tree the
Documents collection (I have 2 item)
5. I inspect the oDocs variable and the value was Nothing

The same code in VBA work.

Help ???





"Brian R. Iwaskewycz" ha scritto nel
messaggio news:54F223059A3E7DA497533409ECAF8C06@in.WebX.maYIadrTaRb...
> I don't think an external VB app is able to determine the document type
> before it's opened. Try changing the line to Dim oDoc as
Inventor.Document.
>
> I haven't tried this so I'm not sure if that's the answer or not (I don't
> have VB).
>
> "Alessio" wrote in message
> news:8E58247214C25F6D2877D3C77A866694@in.WebX.maYIadrTaRb...
> > Why when I try to open a part document with VB id doesn't work? I
obtained
> a
> > VB error 13 Type Mismatch
> >
> > Dim oApp As Inventor.Application
> > Set oApp = GetObject(, "Inventor.Application")
> >
> > Dim oDoc As Inventor.PartDocument
> > Set oDoc = oApp.Documents.Open("c:\mypart.ipt")
> >
> > If I try the same code from VBA it works fine:
> >
> > Dim oDoc As Inventor.PartDocument
> > Set oDoc = ThisApplication.Documents.Open("c:\mypart.ipt")
> >
> >
> >
>
>
Message 4 of 4
Anonymous
in reply to: Anonymous

Try this. This is with only Inventor Object Library referenced. Should
work. I had to specify the document type 'part vs. assy' before being able
to open with VB.net

Dim oInventor As Inventor.Application

Dim oPDoc As Inventor.PartDocument

Dim oADoc As Inventor.AssemblyDocument


"set" oInventor = CreateObject("Inventor.Application") ' the sets are not
needed with VB.net.

oInventor.Documents.Open(sPathandFilename) ' this would have to be an ipt
inorder for teh next line to work correctly.

oPdoc = oInventor.ActiveDocument

oPDoc..Update()

oPDoc..Save()

oPDoc.Close()



John Warren

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report