四种方式写txt

1、这种写出来的是ANSI格式的txt

   Dim TextExportFile As String

    TextExportFile = ThisWorkbook.Path & "\lcx.txt"

    Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(TextExportFile, True) f.WriteLine "罗彩霞:lcx"
f.Close

2、这种是Unicode格式

    Dim TextExportFile As String

    TextExportFile = ThisWorkbook.Path & "\lcx.txt"

    Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(TextExportFile, True, True) f.WriteLine "罗彩霞:lcx"
f.Close

3、这种是UTF-8格式的

Sub WriteTxt(path_, Filename, k)

    Dim tss As String

    'Filename = Application.GetSaveAsFilename(fileFilter:="Text Files (*.txt), *.txt")

    Open path_ & "\" & Filename For Output As #1

    For i =  To k
If Cells(i, ).Value <> "" Then
tss = Cells(i, ) & vbTab & Cells(i, ) & vbTab & Cells(i, ) & vbTab & Cells(i, ) & vbTab & Cells(i, ) & vbTab & Cells(i, )
Print #, tss
End If
Next Close # End Sub

4、这种方式可以设置字符格式

Sub WriteUTF8()
Dim WriteStream As Object
Set WriteStream = CreateObject("ADODB.Stream")
With WriteStream
.Type = 'adTypeText
.Charset = "UTF-8"
.Open
.WriteText "你好utf-8"
.SaveToFile ThisWorkbook.path & "\1.txt", 'adSaveCreateOverWrite
.Flush
.Close
End With
Set WriteStream = Nothing
End Sub

vba txt读写的几种方式的更多相关文章

  1. HBase读写的几种方式(二)spark篇

    1. HBase读写的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一 ...

  2. 【转帖】HBase读写的几种方式(二)spark篇

    HBase读写的几种方式(二)spark篇 https://www.cnblogs.com/swordfall/p/10517177.html 分类: HBase undefined 1. HBase ...

  3. HBase读写的几种方式(一)java篇

    1.HBase读写的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一种 ...

  4. java文件读写的两种方式

    今天搞了下java文件的读写,自己也总结了一下,但是不全,只有两种方式,先直接看代码: public static void main(String[] args) throws IOExceptio ...

  5. HBase读写的几种方式(三)flink篇

    1. HBase连接的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一 ...

  6. .net学习笔记--文件读写的几种方式

    在.net中有很多有用的类库来读写硬盘上的文件 一般比较常用的有: File:1.什么时候使用:当读写件大小不大,同时可以一次性进行读写操作的时候使用         2.不同的方式可以读写文件类型不 ...

  7. VBA遍历数组的2种方式

      1.情景展示 VBA编程,如何对数组进行遍历? 2.解决方案 方式一:使用for循环 Sub 遍历数组1() '声明一个变量 Dim Arr As Variant '声明一个数字变量 Dim i ...

  8. selenium读取txt文件的几种方式

    1.用java读取txt文件 public static String readFJ(String path) { path = "D:/workspace/hetong.txt" ...

  9. python对csv文件读写的两种方式 和 读写文件编码问题处理

    ''' 如果文件读取数据出错,可以考虑加一个encoding属性,取值可以是:utf-8,gbk,gb18030 或者加一个属性error,取值为ignore,例如 open(path, encodi ...

随机推荐

  1. python搭建web server

    假设你急需一个简单的Web Server,但你又不想去下载并安装那些复杂的HTTP服务程序,比方:Apache,ISS等.那么, Python 可能帮助你.使用Python能够完毕一个简单的内建 HT ...

  2. prototype与几个循环的心得

    <一>prototypeprototype其实是函数的一个属性,并且只有函数有这个属性,这个属性就是给函数增加函数或者属性的,比如写一个function one(){},那么one.pro ...

  3. 改动ScrollView的滑动速度和解决ScrollView与ViewPager的冲突

    话不多说,非常easy,能够从凝视中知道做法,直接上代码: 1.改动ScrollView的滑动速度: public class MyHorizontalScrollView extends Horiz ...

  4. 【图像处理】基于OpenCV底层实现的图片旋转

    image processing 系列 [图像处理]直方图匹配 [图像处理]高斯滤波.中值滤波.均值滤波 图片旋转,本质上是对旋转后的图片中每一个像素点计算在原图的位置.然后照搬过来就好. (多说一句 ...

  5. .net的程序的逆向分析。

    背景:碰到一个由c#写的exe,由于之前没有分析过.net的程序,记录下分析流程. 1)peid加载判断类型,可以看出没有加壳. 2)搜索c#的反编译以及调试工具. 1.NET.Reflector以及 ...

  6. 2016/2/22 1、DOM的基本概念 2、Window对象操作 3、Windows.history对象 4、Window.location对象 5、Window.status对象

    1.DOM的基本概念 DOM是文档对象模型,这种模型为树模型:文档是指标签文档:对象是指文档中每个元素:模型是指抽象化的东西. 2.Window对象操作 一.属性和方法: 属性(值或者子对象): op ...

  7. 经典的printk 写法

    经典的printk 写法: printk("[lynn--%s@%d]: addr:0x%x  \n",__func__,__LINE__,obj->client->a ...

  8. ReSharper warns: “Static field in generic type”

    http://stackoverflow.com/questions/9647641/resharper-warns-static-field-in-generic-type It's fine to ...

  9. C#面向过程项目之飞行棋

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 飞行棋V ...

  10. nodejs实现验证码

    http://www.9958.pw/post/nodejs_lesson http://www.9958.pw/post/nodejscapp