CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 1999
    Posts
    3

    WinNT and excel VBA

    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


  2. #2

    Re: WinNT and excel VBA

    What form of automation are you using? DAO, or something else? Do you have the needed libraries registered?


  3. #3
    Join Date
    Sep 1999
    Posts
    3

    Re: WinNT and excel VBA

    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



  4. #4

    Re: WinNT and excel VBA

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured