- Sub example_01()
- ActiveWorkbook.SaveAs "sheet4.txt", FileFormat:=xlText, CreateBackup:=False
- ActiveWorkbook.Close 0
- End Sub
Sub example_01()
ActiveWorkbook.SaveAs "sheet4.txt", FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close 0
End Sub
- Sub example_02()
- Dim x, y(), i&, j&, s$
- x = ActiveSheet.UsedRange.Value
- If IsArray(x) Then
- ReDim y(1 To UBound(x))
- For i = 1 To UBound(x)
- For j = 1 To UBound(x, 2)
- y(i) = y(i) & vbTab & x(i, j)
- Next j
- Next i: s = Join(y, vbCrLf)
- Else
- s = x
- End If
- With CreateObject("scripting.filesystemobject")
- With .CreateTextFile(ThisWorkbook.Path & "\sheet44.txt", True)
- .Write s: .Close
- End With
- End With
- MsgBox "Ok", 64
- End Sub
Sub example_02()
Dim x, y(), i&, j&, s$
x = ActiveSheet.UsedRange.Value
If IsArray(x) Then
ReDim y(1 To UBound(x))
For i = 1 To UBound(x)
For j = 1 To UBound(x, 2)
y(i) = y(i) & vbTab & x(i, j)
Next j
Next i: s = Join(y, vbCrLf)
Else
s = x
End If
With CreateObject("scripting.filesystemobject")
With .CreateTextFile(ThisWorkbook.Path & "\sheet44.txt", True)
.Write s: .Close
End With
End With
MsgBox "Ok", 64
End Sub
|