vba - VBA 将 UTF-8 字符附加到文本文件而不获取“???”
问题描述
您好,我在 MS Access VBA 中工作,我正在编写代码以遍历所有查询定义并将它们附加到文本文件中。当查询 sql 包含 utf-8 字符时,我的输出文件包含“???” 应该出现 UTF-8 字符的位置。我希望 utf-8 字符出现在文本文件中。我的代码如下,任何帮助将不胜感激。
Sub PrintQueries()
Dim strSeparator As String
Dim strFileName As String
Dim returnvalue As Variant
Dim qdef As QueryDef
Dim qdefs As QueryDefs
Dim strQueryName As String
Dim strQuery As String
Dim strdate As String
strdate = Replace(Replace(Now(), "/", "-"), ":", ".")
Set qdefs = Application.CodeDb.QueryDefs
strFileName = "C:\temp\Queries_" & strdate & ".txt"
For Each qdef In qdefs
strQueryName = qdef.Name
If Left(strQueryName, 1) <> "~" Then
Call TxtAppend(strFileName, strQueryName)
strQuery = qdef.SQL '<-- What if strQuery contains utf-8?
Call TxtAppend(strFileName, strQuery) '<-- Call function
strSeparator = "===================="
Call TxtAppend(strFileName, strSeparator)
End If
Next
returnvalue = Shell("notepad.exe" & strFileName, vbNormalFocus)
End Sub
Public Function TxtAppend(strFileName As String, strText As String)
Dim intFileNumber As Integer
intFileNumber = FreeFile
Open strFileName For Append As #intFileNumber
Print #intFileNumber, strText
Close #intFileNumber
End Function
解决方案
推荐阅读
- php - 空数组在 Laravel 刀片中不会显示为空
- javascript - 如何使用 jQuery 或 JavaScript 添加元素?
- mysql - Mysql连接主机每次都在docker容器中更改,为什么?
- c# - 根据条件将复选框设置为签入视图
- vb.net - 如何在对话框 vb.net 中隐藏根文件夹和文件
- inno-setup - 有没有办法在 Inno Setup 中使用 .pas 文件?
- javascript - 更改属性时选择子项的子项
- python - Python中的Unpivot数据框-'builtin_function_or_method'对象没有属性'insert'
- python - TensorFlow 保存和恢复训练好的 CNN 模型不起作用
- c# - Microsoft.Web.Administration 使用特定帐户连接到服务器