excel - 创建后如何写入文本文件?
问题描述
我想从 Excel 中提取单元格 A2 及其偏移量 (0,1) 并将其放入创建的文本文件中。
由于我没有为创建的文本文件声明变量,如何继续?
Sub CreateFileandWrite()
Open ThisWorkbook.Path & "\Test.txt" For Output As #1
Print #1, "Hello"
Print #1, strContent
Close #1
End Sub
解决方案
对于A2及其偏移量:
Sub FileMaker()
Close #1
Open "C:\TestFolder\sample1.txt" For Output As #1
Print #1, Range("A2").Value
Print #1, Range("B2").Value
Close #1
End Sub
推荐阅读
- javascript - 以角度着色单元格xlsx
- python - 是否可以在数据框中格式化数字而不将它们转换为字符串?
- regex - 根据日期和条件返回数组
- java - 如何在片段中从 UserAdapter 实现 holder.itemView.setOnClickListener?
- html - Bootstrap CTA按钮右栏全高
- javascript - 过滤数据后如何在地图中放置标记?
- python - Sounddevice 的 wait() 方法不适用于短声音
- c++ - qml 未知方法返回类型:ArchiveFile*,即使调用了 qmlRegisterUncreatableType
- jquery - 如何使用 jquery 访问父父文本?
- html - 当我尝试检查 request.method == 'POST' 时,为什么我的 Flask 代码出错?