|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
你看看这样是解决了不?
Sub 自动生成TPT8_2()
' Application.ScreenUpdating = False
Application.DisplayAlerts = False
ar = Sheet9.Range("f4:f" & Sheet9.[f65536].End(3).Row)
wm = Split(Sheet9.Range("B4"), ".")(0)
Call 数组生成文件(wm, ar)
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Function 数组生成文件(wm, arr)
On Error Resume Next
'删除文件
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
fso.DeleteFile (ThisWorkbook.Path & "\" & wm & ".TPT")
'复制数据
Dim i As Integer
Dim data As String
For Each ar In arr
data = data & ar & vbCrLf
Next
'创建并保存txt文件
Dim fileName As String
fileName = ThisWorkbook.Path & "\" & wm & ".TPT"
Dim fileNum As Integer
fileNum = FreeFile()
Open fileName For Output As fileNum
Print #fileNum, data
Close fileNum
End Function
|
|