VBA deattach and reattach reference files

Writing a VBA to deattach and then reattach a large amount of reference files. I have all the information except running into problems with reference files that have been

moved. I would like to get their current location and reattach them. Also the display seems not to be working. Below is most of my code.

'Getting information about attached reference files

For Each att In ActiveModelReference.Attachments

If att.DisplayFlag = False Then
  ReferenceFiles(x).Display = False
  att.DisplayFlag = True
  Else
  ReferenceFiles(x).Display = True
  End If
 

    ReferenceFiles(x).filename = att.DesignFile.FullName
    ReferenceFiles(x).Model = att.AttachModelName
    ReferenceFiles(x).Description = att.LogicalDescription
    ReferenceFiles(x).LogicalName = att.LogicalName
    ReferenceFiles(x).Masterorgin = att.MasterOrigin
    ReferenceFiles(x).RefOrgin.Y = att.MasterOrigin
   ReferenceFiles(x).RefOrgin = att.AttachmentOrigin
   
   x = x + 1
           
    Next

'Reattaching reference files

  Do Until x = 1000
   
     
    If ReferenceFiles(x).filename <> "" Then
      attParent.Attachments.Add ReferenceFiles(x).filename, ReferenceFiles(x).Model, ReferenceFiles(x).LogicalName, ReferenceFiles(x).Description, ReferenceFiles(x).RefOrgin, masterpoint, True, ReferenceFiles(x).Display
   End If
   x = x + 1
    Loop