Want to use vb to connect cad drawing automatically, has been cited in the engineering cad object, why still error "ActiveX controls can't create object"
This is my code
Private Sub Command1_Click () Dim cad As AcadApplication The Set cad=GetObject (, "AutoCAD. Application") If Err Then Err. Clear The Set cad=CreateObject (" AutoCAD. Application ") End the If Cad. The Visible=True End Sub I don't think there is wrong, at first thought it was a cad version of the problem and then try the specific version of the code (my cad is 2014)
Private Sub Command1_Click () Dim cad As AcadApplication The Set cad=GetObject (, "AutoCAD. Application. 19") If Err Then Err. Clear The Set cad=CreateObject (" AutoCAD. Application. 19 ") End the If Cad. The Visible=True End Sub Still can't solve, crazy! Pray god help, there's score has sincerely thank 1
CodePudding user response:
You put "green version" CAD?
In VB reference you can see the CAD?
CodePudding user response:
reference 1st floor chewinggum response: you "green version" CAD? In VB reference you can see the CAD? Should not, He has been "reference", certainly can "see", Otherwise, in the Dim cad As AcadApplication prompt "type is not defined" (probably is this error message), such As CodePudding user response:
I wonder, could it be that the CAD software itself, Its "COM interface compatibility" (or "adaptive") is not good, some environments cannot function properly, CodePudding user response:
Dim cad As new AcadApplication start CodePudding user response:
reference 4 floor chewinggum response: Dim cad As new AcadApplication Start Be careful button, and then prompt "OLE automation error" (such as probably is this meaning... ), CodePudding user response:
Do not think that with the New code doesn't have to write the CreateObject, so the process of "Create" is really jumps over... In fact just "it do for you", CodePudding user response:
The reference 3 floor Chen8013 response: , I was thinking will be CAD software itself, Its "COM interface compatibility" (or "adaptive") is not good, some environments cannot function properly, But there is a strange problem, when I put the Set MyCad=GetObject (, "AutoCad. Application. 19"), directly under the condition of the cad not open use createobject, can connect cad Then under the condition of cad has been opened with getobject, can get to the cad,,,,,,, mad,,,, CodePudding user response:
reference 5 floor Chen8013 reply: Quote: refer to 4th floor chewinggum response: Dim cad As new AcadApplication Start Be careful button, and then prompt "OLE automation error" (such as probably is this meaning... ), But I'll code the front and on the error resume next, and then remove the if statement, you can run the code, but I don't want to use on erroe resume next, Afraid of the back of the program has a mistake, I can't find out, in fact use one rror and if err is to determine whether cad to open, why is the if err statement every time appear unable to create The object of error, ah CodePudding user response:
In a 64 - bit Windows: 64 exe and DLL in the directory c: \ Windows \ sys tem32 directory. 32 bit exe and DLL in the directory c: \ Windows \ sys wow64 directory. So pay attention to: In win64 system registered under 32-bit ocx DLL to 32 ocx or copy the DLL to the c: \ Windows \ syswow64 \ directory, And registered to c: \ Windows \ syswow64 \ regsvr32 XXXXXXX ocx or DLL A 64 - bit Windows platform attention point of the file system redirection http://www.cnblogs.com/jiake/p/4981555.html 64 - bit Windows platforms attention point of the registry to redirect http://www.cnblogs.com/jiake/p/4956218.html CodePudding user response:
refer to the eighth floor DQYDXT response: Quote: refer to the fifth floor Chen8013 reply: Quote: refer to 4th floor chewinggum response: Dim cad As new AcadApplication Start Be careful button, and then prompt "OLE automation error" (such as probably is this meaning... ), But I'll code the front and on the error resume next, and then remove the if statement, you can run the code, but I don't want to use on erroe resume next, Afraid of the back of the program has a mistake, I can't find out, in fact use one rror and if err is to determine whether cad to open, why is the if err statement every time appear unable to create Object of mistake, ah "There is an error", i.e., you use on the error resume next, to take the blame "properly"!!!!!! "Run", compared to the "run correctly", is a far cry from!!!!!! CodePudding user response:
references to the tenth floor Chen8013 response: Quote: refer to the eighth floor DQYDXT response: Quote: refer to the fifth floor Chen8013 reply: Quote: refer to 4th floor chewinggum response: Dim cad As new AcadApplication Start Be careful button, and then prompt "OLE automation error" (such as probably is this meaning... ), But I'll code the front and on the error resume next, and then remove the if statement, you can run the code, but I don't want to use on erroe resume next, nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull