小编Neh*_*eha的帖子

附加到文本文件VBA

我需要将选定范围内的值转换为逗号分隔的文本文件并附加它们.下面的代码在Set TS给出了一个错误.为什么??

Sub Wri()

Dim myrng As Range
Dim Cell As Range

On Error Resume Next
Set myrng = Application.InputBox("Select range", Type:=8)
On Error GoTo 0

If myrng Is Nothing Then
    MsgBox "No cells selected"
    Exit Sub
End If

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

Dim fs, f, TS, s
Dim cellv As String

Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "C:\Users\HP\Documents\fil.txt"
Set f = fs.GetFile("C:\Users\HP\Documents\fil.txt")
Set TS …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba delimited-text

4
推荐指数
1
解决办法
6万
查看次数

标签 统计

delimited-text ×1

excel ×1

excel-vba ×1

vba ×1