自定义属性文本字体
问题描述:
我创建了一个将我的自定义属性导入到Solidworks零件文件的宏。问题在于Solidworks似乎不理解我选择的VBA文本字体并导入修改后的文本。任何人都可以帮我解决这个问题吗? You can see the altered text here.自定义属性文本字体
答
我不认为我可以测试这一点,因为我的安装使用英语的ASCII编码,它似乎使用的是我不能使用的字符,但我发现这个代码转换ASCII to Unicode:
Public Function AsciiToUnicode(sText As String) As String
Dim saText() As String, sChar As String
Dim sFinal As String, saFinal() As String
Dim x As Long, lPos As Long
If Len(sText) = 0 Then
Exit Function
End If
saText = Split(sText, ";") 'Unicode Chars are semicolon separated
If UBound(saText) = 0 And InStr(1, sText, "&#") = 0 Then
AsciiToUnicode = sText
Exit Function
End If
ReDim saFinal(UBound(saText))
For x = 0 To UBound(saText)
lPos = InStr(1, saText(x), "&#", vbTextCompare)
If lPos > 0 Then
sChar = Mid$(saText(x), lPos + 2, Len(saText(x)) - (lPos + 1))
If IsNumeric(sChar) Then
If CLng(sChar) > 255 Then
sChar = ChrW$(sChar)
Else
sChar = Chr$(sChar)
End If
End If
saFinal(x) = Left$(saText(x), lPos - 1) & sChar
ElseIf x < UBound(saText) Then
saFinal(x) = saText(x) & ";" 'This Semicolon wasn't a Unicode Character
Else
saFinal(x) = saText(x)
End If
Next
sFinal = Join(saFinal, "")
AsciiToUnicode = sFinal
Erase saText
Erase saFinal
End Function
+1
非常感谢!这真的起作用了。 –
你有没有试过用VSTA做这个? –
不Iam不熟悉VSTA编程 –
我认为VBA编辑器只是ASCII扩展。你可以尝试使用wchar编码字符串吗? –