将英文名称转换成阿拉伯语的Excel函数 [英] Excel Function To Convert English Names To Arabic
本文介绍了将英文名称转换成阿拉伯语的Excel函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
功能Translate_To_Arabic(str)As String
'工具Refrence选择Microsoft Internet Control
Dim IE As Object,As As Long
Dim inputstring As String,outputstring As String, text_to_convert As String,result_data As String,CLEAN_DATA
设置IE = CreateObject(InternetExplorer.application)
'选择输入语言
inputstring =auto
'选择输出语言
outputstring =ar
text_to_convert = str
'打开网站
IE.Visible = False
IE.navigatehttp://translate.google.com/#&输入字符串/&输出串/& text_to_convert
Do Until IE.ReadyState = 4
DoEvents
循环
Application.Wait(Now + TimeValue(0:00:5) )
直到IE.ReadyState = 4
DoEvents
循环
CLEAN_DATA =拆分(Application.WorksheetFunction.Substitute(IE.Document.getElementById对于j = LBound(CLEAN_DATA)到UBound(CLEAN_DATA)
result_data =b,$,&/ SPAN>, result_data& (CLEAN_DATA(j)) - InStr(CLEAN_DATA(j),>))
$ b transalte_using_vba = result_data
结束函数
解决方案
问题是你的最后一行代码应该是:
Translate_To_Arabic = result_data
你误读了翻译
确保您添加了对Microsoft Internet控件的引用
I am trying to add a VBA function to my excel sheet were I can translate or convert the names to arabic to stop them in my database. I added the developer tab and open editor and I added the following function but it is not working...Any help please
Function Translate_To_Arabic(str) As String
' Tools Refrence Select Microsoft internet Control
Dim IE As Object, i As Long
Dim inputstring As String, outputstring As String, text_to_convert As String, result_data As String, CLEAN_DATA
Set IE = CreateObject("InternetExplorer.application")
' TO CHOOSE INPUT LANGUAGE
inputstring = "auto"
' TO CHOOSE OUTPUT LANGUAGE
outputstring = "ar"
text_to_convert = str
'open website
IE.Visible = False
IE.navigate "http://translate.google.com/#" & inputstring & "/" & outputstring & "/" & text_to_convert
Do Until IE.ReadyState = 4
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:5"))
Do Until IE.ReadyState = 4
DoEvents
Loop
CLEAN_DATA = Split(Application.WorksheetFunction.Substitute(IE.Document.getElementById("result_box").innerHTML, "</SPAN>", ""), "<")
For j = LBound(CLEAN_DATA) To UBound(CLEAN_DATA)
result_data = result_data & Right(CLEAN_DATA(j), Len(CLEAN_DATA(j)) - InStr(CLEAN_DATA(j), ">"))
Next
IE.Quit
transalte_using_vba = result_data
End Function
解决方案
The problem is that your last line of the code should be:
Translate_To_Arabic = result_data
You have mispeeled "Translate"
Also make sure you added the Reference to the Microsoft Internet Controls
这篇关于将英文名称转换成阿拉伯语的Excel函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文