Sub Export_mass_area_res_sn() Dim precursor As Double 'Get the precursor mass. If this is NOT an MS/MS file, it will be <= 0 ActiveDocument.InstrumentSettings.GetSetting dePreCursorIon, 0, precursor 'Retrieve the peak list Dim peaks As Variant Dim numPeaks As Long numPeaks = ActiveDocument.SpecView.GetPeakData2(deSpecPeak2All, deSpecPeakSortMass, 0, 0, peaks) Dim filename As String 'Name the mascot file after the spectrum filename filename = ActiveDocument.FullName Dim filenameParts() As String, pathParts() As String 'Remove the file extension filenameParts = Split(filename, ".") 'Remove the directory path pathParts = Split(filenameParts(0), "\") Dim title As String title = pathParts(UBound(pathParts)) 'Open the text file in the same path as the spectrum file filename = "" Dim i As Long For i = 0 To UBound(pathParts) - 1 filename = filename & pathParts(i) & "\" Next i filename = filename & title & ".txt" Dim fs As Object, A As Object Set fs = CreateObject("Scripting.FileSystemObject") Set A = fs.CreateTextFile(filename, True) 'Write out only the monoisotopic peaks If precursor > 0 Then A.WriteLine ("BEGIN IONS") A.WriteLine ("TITLE=" & title) A.WriteLine ("PEPMASS=" & precursor) ' A.WriteLine ("Mass" & vbTab & "IsotopeClusterArea" & vbTab & "Resolution" & vbTab & "S/NRatio" & vbTab & "Height") For i = 0 To numPeaks - 1 If peaks(i, deSpecPeak2IsotopeClusterArea) > 0 Then ' A.WriteLine (peaks(i, deSpecPeak2Mass) & vbTab & peaks(i, deSpecPeak2IsotopeClusterArea) & vbTab & peaks(i, deSpecPeak2Resolution) & vbTab & peaks(i, deSpecPeak2SNRatio) & vbTab & peaks(i, deSpecPeak2PeakHeight)) A.WriteLine (peaks(i, deSpecPeak2Mass) & vbTab & peaks(i, deSpecPeak2IsotopeClusterArea)) End If Next i A.WriteLine ("END IONS") Else A.WriteLine ("Mass" & vbTab & "Area" & vbTab & "Resolution" & vbTab & "S/NRatio" & vbTab & "Height") For i = 0 To numPeaks - 1 'If peaks(i, deSpecPeak2IsotopeClusterArea) > 0 Then' A.WriteLine (peaks(i, deSpecPeak2Mass) & vbTab & peaks(i, deSpecPeak2Area) & vbTab & peaks(i, deSpecPeak2Resolution) & vbTab & peaks(i, deSpecPeak2SNRatio) & vbTab & peaks(i, deSpecPeak2PeakHeight)) 'End If' Next i End If A.Close End Sub