这个需要用VBA代码来完成,如下:
Sub test()
Dim rG As Range, wb As Workbook
f = MsgBox("已经选好数据区域了吗?" & Chr(10) & "Yes----选好了。 No------还没有。", vbYesNo, "已经选好数据区域了吗?")
If f = 7 Then Exit Sub
Application.DisplayAlerts = False
Set rG = Selection
Workbooks.Add
With ActiveWorkbook
rG.Copy .Worksheets(1).Cells(1, 1)
.SaveAs ThisWorkbook.Path & "\新文件.txt", FileFormat:=xlText
.Close True
End With
Application.DisplayAlerts = True
MsgBox "处理结束,在生成了一个名为“新文件.txt”的文本文件"
End Sub
附件中有样本文件,以供测试!