Click to See Complete Forum and Search --> : WinNT and excel VBA


Randy Berg
January 10th, 2000, 11:53 AM
This excel VBA procedure runs alright in Win98 but not WinNT. The procedure opens and closes an autocad application and has 2 message boxes for debugging. How do I make it work in WinNT?

Thank you for your help.



Dim otherApp As Object 'otherApp is autocad R14 application

Sub get_acad()
Dim fname As Variant

fname = Excel.Application.GetOpenFilename("Drawing (*.dwg),*.dwg", , "Open AutoCAD drawing to extract BOM text.")
If fname = False Then Exit Sub

MsgBox "fname= " + fname, , "Selected Filename" 'debug line

On Error Resume Next
Set otherApp = GetObject(fname) ' ***automation type errors occur at this line in WinNT***
If Err Then
MsgBox "Error description: " + Err.Description, , "Error finding AutoCAD" 'debug line
Exit Sub
End If
Err.Clear

otherApp.Application.Quit
Set otherApp = Nothing
End Sub

wilton
January 10th, 2000, 07:51 PM
What form of automation are you using? DAO, or something else? Do you have the needed libraries registered?

Randy Berg
January 11th, 2000, 02:10 PM
I'm not sure what form of automation is used (I'm new to this area). However in excel, the error occurs when the new object is created (the autocad drawing). See the previously posted code for the details.

The excel app is password protected. Can the VBA object reference be set programmactically? It seems that the path of the autocad type file reference varies from one computer installation to another.

Thank you for your response. Randy Berg

wilton
January 11th, 2000, 03:26 PM
Put a break on the code here:
fname = Excel.Application.GetOpenFilename("Drawing (*.dwg),*.dwg", , "Open AutoCAD drawing to extract BOM text.")
See what value it assigns to fname. Make sure that it is assigning something.

Another thing. I would try creating an object setting it equal to excel.application and use this in place of excel.application in the fname declaration.

It's possible also that because it's AutoCad running on NT that auto cad is using some sort of verification procedure. Autodesk has to be careful that an unauthorized number of lisences aren't being used. So check the autodesk help file and see what it says. I'd swear it has entries in in about using vba for automation.

If that doesn't work repost, and I'll install R14 and try your code on my machine.