The codes are as below :
Public objAcad As Object
Public objDoc As Object
Private Sub StartAutoCAD()
Dim DwgName As String
On Error Resume Next
Set objAcad = GetObject(, "AutoCAD.Application")
If Err Then
Set objAcad = CreateObject("AutoCAD.Application")
Err.Clear
End If
If Right(App.Path, 1) = "\" Then
DwgName = App.Path & "facility.dwg"
Else
DwgName = App.Path & "\facility.dwg"
End If
Set objDoc = objAcad.ActiveDocument
I don't know why it wouldn't start and the worse thing is that there is
no error meesage. When clicked the button launch acad, nothing
happens, no window of ACAD2K came out, no error, nothing happen.
I tried to change createobject or getobject from AutoCAD.Application to
AutoCAD.Application.15. Still nothing happened. I hope there is some one
out there knows what's wrong with my codes. Is it a path problem???
Warmest Regards
Ng Kok Weng
objAcad.Visible = True
Stephan
ACAD2K was launched at all. My suspect is that it has something to do with the
path and probably something in the registry. I do hope someone knows the
details of ACAD2K registration, etc. I have tried to launch ACAD2K with
ShellExecute
and Shell (APIs) and it worked. However when I specified a wrong path in those
APIs, similar situation happened .. i.e. nothing happen. However I have no
idea
where to check ACAD2K library path setting and registration.
Take a look in the registry:
HKEY_CLASSES_ROOT\AutoCAD.Application\CLSID
and then
HKEY_CLASSES_ROOT\CLSID\[The value from above]\LocalServer32
-> there you should find the path to your acad.exe,
if it is the wrong path, change it; if the path
is right then I think you have to reinstall AutoCAD...
HKEY_CLASSES_ROOT\AutoCAD.Application and HKEY_CLASSES_ROOT\AutoCAD.Application.15
For HKEY_CLASSES_ROOT\AutoCAD.Application, there are 2 folders CLSID and CurVer. The
value for
CLSID is {8E75D911-3D21-11d2-85C4-080009A0C626}. While the CurVer has value of
"AutoCAD.Application.15".
The other HKEY_CLASSES_ROOT\AutoCAD.Application.15 has a single folder under it
which is CLSID and the value is the same, {8E75D911-3D21-11d2-85C4-080009A0C626}.
The HKEY_CLASSES_ROOT\CLSID\[The value from above]\LocalServer32 has the path
"d:\Program Files\AutoCAD Architectural 2\acad.exe /Automation" which is the right
path but is the "/Automation" needed?? Anyhow, there are 2 more
folders under HKEY_CLASSES_ROOT\CLSID\{8E75D911-3D21-11d2-85C4-080009A0C626} which
is Progid folder ( has "AutoCAD.Application.15 " as its value) and
VersionIndependentProgId (has value "AutoCAD.Application").
I was wondering whether this "sometimes" AutoCAD.Application.15 and sometimes
AutoCAD.Application causes any
confusions to PC.
After further checking, there is another HKEY_CLASSES_ROOT\CLSID next to the one
above which is {8E75D913-3D21-11D2-85C4-080009A0C626} which has a lot more folder
under it i.e. AuxUserType, DefaultIcon,
InProcHandler32, Insertable, LocalServer32, MiscStatus, ProgId, Verb and it is used
by AutoCAD.Drawing
(HKEY_CLASSES_ROOT\AutoCAD.Drawing. In fact I have 2 AutoCAD.Drawing, one without
extension.15 and one
AutoCAD.Drawing.15. Is this Registry AutoCAD.Drawing supposed to have the same CSLID
with AutoCAD.Application?
Thank you.
Regards
Ng Kok Weng
Stephan Koster wrote:
> Your code works for me as expected.
>
> Take a look in the registry:
>
> HKEY_CLASSES_ROOT\AutoCAD.Application
>
The only thing that is different from my settings:
I have no spaces in my path name.
You can try to eliminate the spaces by using
the short name: in the explorer select
d:\Program Files and look in the properties
for the short name (should be something like
progra~1) and do the same for
d:\Program Files\AutoCAD Architectural 2
and then replace the value in the registry
(should be something like
"D:\progra~1\autoca~1\acad.exe /Automation")
If this doesn't work you can try to get more
help in the vba newsgroup.
Cheers