excel - 使用 VBA 删除 .txt 文件中的字符
问题描述
我正在 VBA 中创建一个程序,该程序在 Excel 中的电子表格上获取表格数据,然后将每一行作为字符串打印到 .txt 文件(将保存为 .jet 文件)。它从一个只是硬编码字符串文字的标题开始,然后打印每个 Excel 行,在该行的单元格之间交织字符串文字。在最后,它添加了一个页脚,它只是结束大括号。我坚持的部分是我无法弄清楚如何删除 .txt 文件中的最后一个逗号,因为逗号仅用于分隔数据中的条目。到目前为止,我已经准备了一个与输出文本类似的示例,其中包括我要删除的最后一个逗号:
{"myid":345,"content":[ {"question": "A triangle is a shape with three straight sides?","answer": true}, {"question": "The moon is a planet","answer": false},
编辑:这是一些代码的示例。我知道其中一半不是真正的 VBA 代码或任何代码,但我试图说明我的意思:
Open Application.ActiveWorkbook.Path & "\" & filename For Edit As #1 ‘yes, I know there is no such “Edit”
Edit #1 SendKeys (bkspce) ‘yes, I know this is wrong. im just saying something like sending a command to backspace, which wouldn’t work with SendKeys because it takes strings as arguments
Close #1
End Sub
解决方案
推荐阅读
- python - 如何选择标签
- macos - Android studio 返回无法下载 gradle 并且还有缓存问题是什么意思?
- plc - 整个功能块真的存储在 RETAIN 内存中吗?
- c# - WebView2如何加载本地文件?
- sql - 如何在 2 个表之间建立链接?
- react-native - react-native-webview 中的按钮
- python - 计算连续的字母
- javascript - 使用部分 GLTF 作为 InstancedMesh
- flutter - 即使启用了 Flutter cloud_firestore 持久性也无法正常工作
- spring-data-gemfire - 升级到 spring-geode-starter 1.4.2 会产生条件、内省和 ClassNotFoundExceptions