Results 1 to 6 of 6

Thread: Use EXCEL VBA to load AutoCAD reference files

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2010-07
    Posts
    1
    Login to Give a bone
    0

    Default Use EXCEL VBA to load AutoCAD reference files

    How can I use Excel VBA to determine the AutoCAD versionin use and then automatically load the appropriate reference files?

    I have set up a spread sheet that allows Project Managers to define the layout for electrical enclosures.

    Running this on my PC, I can create a drawing in about 10 seconds that would normally take about 4-5 hours.

    What I need now if for this spread sheet to be able to be used on any version of AutoCAD without the user needing to manually load the library reference files.

    I have spent about 3 days searching the net trying to find the relavent code but it seems very allusive so I would appreciate any help that anyone may be able to provided

  2. #2
    All AUGI, all the time arshiel88's Avatar
    Join Date
    2005-02
    Location
    Off the Grid
    Posts
    560
    Login to Give a bone
    0

    Default Re: Use EXCEL VBA to load AutoCAD reference files

    Have you looked upon the system variable ACADVER?

  3. #3
    Active Member
    Join Date
    2008-02
    Location
    Central IL
    Posts
    53
    Login to Give a bone
    0

    Default Re: Use EXCEL VBA to load AutoCAD reference files

    If you open an AutoCAD file in notepad, the first six characters contain a code that correlates to the AutoCAD version.

    Here are the codes and corresponding versions.

    AC1027 AutoCAD 2013
    AC1024 AutoCAD 2010/2011/2012
    AC1021 AutoCAD 2007/2008/2009
    AC1018 AutoCAD 2004/2005/2006
    AC1015 AutoCAD 2000/2000i/2002
    AC1014 Release 14
    AC1012 Release 13
    AC1009 Release 11/12
    AC1006 Release 10
    AC1004 Release 9
    AC1003 Version 2.60
    AC1002 Version 2.50
    AC1001 Version 2.22
    AC2.22 Version 2.22
    AC2.21 Version 2.21
    AC2.10 Version 2.10
    AC1.50 Version 2.05
    AC1.40 Version 1.40
    AC1.2 Version 1.2
    MC0.0 Version 1.0

    As new releases become available, new codes will probably be added. I'm not sure how files that were created with products other than AutoCAD show up, so you'll have to look into that.


    Here's a simple excel VBA function that could be used to extract the first 6 characters of any text file. Put it in a module, and it should be available to you in any cell.

    Code:
    Public Function GetAcadVersion(ByVal FileName As String) As String
        Dim TextLine As String
        Open FileName For Input As #1    ' Open file.
        Line Input #1, TextLine    ' Read line into variable.
        GetAcadVersion = Left(TextLine, 6)
        Close #1    ' Close file.
    End Function
    AcadVersionFromFileExample.xls
    I also attached a sample excel file to get you started.

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Use EXCEL VBA to load AutoCAD reference files

    Determining the acadver is only part of the problem. A dvb is itself a specially compiled dll that includes not just the text you see in the IDE, but also the compiled code. That means that if you expect to run the same dvb (i.e. a network location) on all versions, you'll hit a wall. For example, let's say that you authored the dvb on a pc running 2010. Next, a user running 2013 loads the dvb. Upon doing so, acad automatically updates the reference to the 2013 olb and then does a compile. Now, you come back to use it and try to load the file and 2010 can't read it, so the load fails. Its similar to the case that acad upconverts dwg's on load, but then older versions can no longer read the dwg. So, you need to provide each user with a local version of the dvb that works with their version of acad.
    C:> ED WORKING....

  5. #5
    Woo! Hoo! my 1st post
    Join Date
    2015-09
    Posts
    1
    Login to Give a bone
    0

    Default Re: Use EXCEL VBA to load AutoCAD reference files

    I am very interested in know how you setup and layout your spread sheet in excel to create a electrical enclosures in Autocad electrical

  6. #6
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    487
    Login to Give a bone
    0

    Default Re: Use EXCEL VBA to load AutoCAD reference files

    First I need to know are you running the program in the Excel file or AutoCad file.
    If form the Excel file, make VBA Module for each version of AutoCAD you will be using. name so you know witch version it runs in.
    How come the hard part all Macros and functions that using AuotCAD will need to be change to check witch version you are working with and call the right Macro or functions.
    This could be done, by set a public variable, that is check, with a Function or Macro is called, then that function calls the function or Macro in the right version of AutoCAD.

    Note. You Should change the name of all Macros and functions in the new module. exp: oldfunction to oldfunctionXX where the XX is the AutoCad Version.
    Only move Function and sub that call Autocad to the new VBA Module

    If form AutoCAD make a dbv file for each version of Autocad and load that Version.
    Note. If you auto load the dbv file, you Should be able to write a program to Check the Version of AutoCAD and load the right Dbv file.
    Last edited by jwanstaett; 2014-08-29 at 06:02 PM.

Similar Threads

  1. 2011: EXCEL FILES IN AUTOCAD
    By vtmiii in forum AutoCAD General
    Replies: 6
    Last Post: 2010-07-12, 05:16 PM
  2. Excel Files in Autocad
    By rhayes.99001 in forum ACA General
    Replies: 4
    Last Post: 2006-12-05, 02:27 PM
  3. Replies: 10
    Last Post: 2006-07-25, 11:43 PM
  4. Link Excel files to AutoCAD
    By robert.1.hall72202 in forum AutoCAD Customization
    Replies: 21
    Last Post: 2006-05-23, 01:24 AM
  5. Autocad 2005 & Excel files. (.xls)
    By epiphane.kavegue in forum AutoCAD General
    Replies: 2
    Last Post: 2005-10-17, 03:48 PM

Posting Permissions

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