2016-01-05 153 views
1

我創建了一個將我的自定義屬性導入到Solidworks零件文件的宏。問題在於Solidworks似乎不理解我選擇的VBA文本字體並導入修改後的文本。任何人都可以幫我解決這個問題嗎? You can see the altered text here.自定義屬性文本字體

Solidworks output

enter image description here

+0

你有沒有試過用VSTA做這個? –

+0

不Iam不熟悉VSTA編程 –

+0

我認爲VBA編輯器只是ASCII擴展。你可以嘗試使用wchar編碼字符串嗎? –

回答

1

我不認爲我可以測試這一點,因爲我的安裝使用英語的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

非常感謝!這真的起作用了。 –