Attribute VB_Name = "sapphos" Sub processThisMXD(filePath As String, destFilePath As String) Dim pApp As IApplication Dim pMxDoc As IMxDocument Dim strDocPath As String Dim pTemplates As ITemplates Dim lTempCount As Long Dim fs Debug.Print filePath & " ::: " & destFilePath Set pApp = New AppRef Set pMxDoc = pApp.Document ' MsgBox (pApp.Name) pMxDoc.RelativePaths = True ' MsgBox (pMxDoc.RelativePaths) Set pTemplates = pApp.Templates lTempCount = pTemplates.Count ' The document is always the last item strDocPath = pTemplates.Item(lTempCount - 1) ' MsgBox (strDocPath) Call pApp.SaveDocument(strDocPath) txtFileName = Left$(filePath, Len(filePath) - 4) & ".txt" Set fs = CreateObject("Scripting.FileSystemObject") If (fs.FileExists(txtFileName)) Then fs.DeleteFile (txtFileName) End If If (fs.FileExists(destFilePath)) Then fs.DeleteFile (destFilePath) End If Dim ls As LayerSource Set ls = New LayerSource Call ls.LayerSourceArray Call fs.MoveFile(txtFileName, destFilePath) End Sub Sub shutdown() Dim pApp As esriFramework.IApplication Set pApp = New AppRef pApp.shutdown End Sub