0

I am using vb6.0 application to interact with autocad. i am using autocad2007. While i run my application in autocad2007 no problem it's working fine. When i need to interact with autocad2010 my application doesn't work. So i changed reference Autocad 2010 type library. Now it's working fine only in autocad2010 but not working in autocad2007. So any body help to me to add reference type library at runtime based on autocad version.

Fred
  • 5,663
  • 4
  • 45
  • 74
Sivaperuman
  • 239
  • 1
  • 4
  • 21

1 Answers1

0

Assuming the dll names, method names and parameters, and properties are all the same you need to create the object in code rather than through the Project | References** menu. You can still add the reference to get the intellisense.

for instance, instead of ...

Dim objWApp As Word.Application
Set objWApp = new Word.Application

use ...

Dim objWApp As Object
Set objWApp = CreateObject("Word.Application")
jac
  • 9,666
  • 2
  • 34
  • 63
  • 1
    To expand on Jac's post, the AutoCAD ProgIds you'd call are "AutoCAD.Application.17" for 2007, and "AutoCAD.Application.18" for 2010. Simply calling "AutoCAD.Application" (which the AcadApplication COM object's constructor uses I believe) creates an object based on what was last opened. – Parrish Husband Dec 19 '13 at 23:41
  • As per your information while i try to create the object of autocad type mismatch runtime error occurred. Based on referenced type library version i can create the object of corresponding autocad only. Other version of autocad unable to create the object. – Sivaperuman Dec 20 '13 at 05:10
  • Do you think you can post the code where this is failing? From experience I know sometimes certain methods won't be available between versions. – Parrish Husband Dec 20 '13 at 13:31
  • jac, my previous comment was directed at @Sivaperuman. I'll gladly post my own code in the form of an answer if applicable, but I need to understand what the OP is trying to do in the big picture. – Parrish Husband Dec 20 '13 at 15:37
  • @Locke My bad. I read your comment and thought it was from the OP. – jac Dec 20 '13 at 17:28