Detaching reference files in vba

All,

I have an app which attaches an arbitrary number of reference files, then copies all elements on a level to the master dgn. When this process is complete I want to detach all the reference files. Is there a method which does that all is one shot or do I need to detach them one by one?

Thanks

Parents
  • LonADunham said:
    I want to detach all the reference files

    There's the Attachments.Remove method.  This detaches a single attachment, given its index, name, or object.  As with most collections, someone has to iterate each member in order to detach it.

    When removing items from a collection, remember to iterate from the end back to the beginning. Otherwise, you'll have undefined results …

    Dim nAttachments As Integer
    nAttachments = ActiveModelReference.Attachments.Count
    Dim i As Integer
    For i = Count To 1 Step -1
       ActiveModelReference.Attachments.Remove i
    Next i

    Does that make queuing the keyin look easier?

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply
  • LonADunham said:
    I want to detach all the reference files

    There's the Attachments.Remove method.  This detaches a single attachment, given its index, name, or object.  As with most collections, someone has to iterate each member in order to detach it.

    When removing items from a collection, remember to iterate from the end back to the beginning. Otherwise, you'll have undefined results …

    Dim nAttachments As Integer
    nAttachments = ActiveModelReference.Attachments.Count
    Dim i As Integer
    For i = Count To 1 Step -1
       ActiveModelReference.Attachments.Remove i
    Next i

    Does that make queuing the keyin look easier?

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children
No Data