|
wanapen 发表于 2013-5-9 16:49
首先谢谢alzeng 老师的语句支持~~~
但是我发现您给的语句只支持单个.xls文件写入TXT 如果是多个.xls写入 ...
- Sub wrtInTxt()
- Dim oClp As Object
- Dim Flnm, Str$, k%
- Dim Wb As Workbook
- Set oClp = CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
- Flnm = Application.GetOpenFilename("Excel文件,*.xls", , "请选择", , True)
- For k = 1 To UBound(Flnm)
- Set Wb = GetObject(Flnm(k))
- Wb.Sheets(1).[A6].CurrentRegion.Copy '此处假设所有文件格式相同
- oClp.getfromclipboard: Str = oClp.gettext
- [A1].Copy: Wb.Close 0
- Open ThisWorkbook.Path & "\模板文件.txt" For Append As #1
- Print #1, Str: Reset
- Next
- Set oClp = Nothing
- MsgBox "数据已写入文本中。"
- End Sub
复制代码
等Zamyi更好的方法…… |
评分
-
1
查看全部评分
-
|