Changing the name of an alignment in LDD with VBA

Discussion in 'AutoCAD' started by David Urban, Feb 22, 2005.

  1. David Urban

    David Urban Guest

    Hello all you LDDers

    I want to change the name of an alignment in LDD. IE a street name
    changes. I know where in the database(access) to change it. and all of
    the files, but I want to do it in VBA. does any one have an example of
    changing filename and changing information in an access database or an
    example of changing an alignment.

    David Urban
     
    David Urban, Feb 22, 2005
    #1
  2. David Urban

    David Urban Guest

    Jeff

    Thanks that works. It works to change the database. Now how do I
    change the file names in the align directory. this should be easy for
    any VBA guru. I just need to change a directory name and a file name.

    Thanks

    David Urban
     
    David Urban, Feb 23, 2005
    #2
  3. Hi David,

    VBA has a "FileCopy" function and a "Kill" function. Use the copy, then the
    Kill on the original.

    You should do a Dir of the file to check it exists before doing the other
    two commands. You may even care to do a Dir of the copy before deleting the
    original.

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Feb 23, 2005
    #3
  4. David Urban

    Oberer Guest

    I rarely use this, so it's pretty ugly and hard-coded. It should get you started :)
    It's been a while since I've used this. If you rename the directory (your alignment), this should rename all the files to match the dir name

    Code:
    Sub FIX_ALIGNMENT_FILES()
    
    Dim MyPath As String
    Dim MyName As String
    
    Dim NEW_Dir As String
    
    NEW_Dir = "ST-JASMINE DR"
    ' Display the names in C:\ that represent directories.
    
    MyPath = "\\Nt2\engineering\LD Projects\Windbrooke\align\" & NEW_Dir & "\"   ' Set the path.
    MyName = Dir(MyPath, vbDirectory)    ' Retrieve the first entry.
    Do While MyName <> ""    ' Start the loop.
    ' Ignore the current directory and the encompassing directory.
    If MyName <> "." And MyName <> ".." Then
    ' Use bitwise comparison to make sure MyName is a directory.
    Debug.Print MyName
    If (GetAttr(MyPath & MyName) And vbDirectory) <> vbDirectory Then
    Debug.Print MyPath & MyName & MyPath & NEW_Dir & Right(MyName, 4)
    FileCopy MyPath & MyName, MyPath & NEW_Dir & Right(MyName, 4)
    Debug.Print "CREATED: " & MyPath & NEW_Dir & Right(MyName, 4)
    'If Dir(MyPath & "TEST" & Right(MyName, 4), vbNormal) > 0 Then
    Kill MyPath & MyName
    Debug.Print "DELETED: " & MyPath & MyName
    'End If
    Debug.Print MyName    ' Display entry only if it
    
    End If    ' it represents a directory.
    End If
    MyName = Dir    ' Get next entry.
    Loop
    
    End Sub
    
     
    Oberer, Feb 23, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.