I have this VBA that works correctly with AutoCad version 2008 but when tried on a AutoCad 2012 we are getting the following error - usually I get this error when AutoCad is not opened and it is opened:
Run-time error '-2147352571 (80020005)':
Cannot run 'AUTOCAD..EXE'. The program or one of its components is damaged or missing.
---------
Here is the code:
Private Function SendCommands(CommandString As String) As Boolean
If Len(CommandString) - InStrRev(CommandString, vbCr) > 2 Then
CommandString = CommandString & vbCr
End If
MyVersion = Range("D1")
If MyVersion = "2008" Then App = "AutoCad.R17.DDE"
If MyVersion = "2010" Then App = "AutoCad.R18.DDE"
If MyVersion = "2011" Then App = "AutoCad.R181.DDE"
If MyVersion = "2012" Then App = "AutoCad.R182.DDE"
If MyVersion = "2013" Then App = "AutoCad.R183.DDE"
Dim Drawing As String
Drawing = Application.DDEInitiate(App:=App, topic:="system")
Application.DDEExecute Drawing, CommandString
End Function