2013-12-16 44 views
1

我想使用LtrPara()方法在Word文檔中設置從左到右的對齊方式。
不幸的是,它什麼也沒做,文字從RTL開始。任何想法?從RTL設置Word.Selection LTR

Microsoft.Office.Interop.Word.Document wordDoc = null; 
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); 
wordDoc = wordApp.Documents.Add(ref defaultTemplate, ref missing, ref missing, ref missing); 
//make a word selection object 
Microsoft.Office.Interop.Word.Selection selection = wordApp.Selection; 
selection.LtrPara(); 

在此先感謝!

+0

是否有我們應該注意的區域設置?例如,你是否在RTL是常態的文化設置中運行? – neontapir

+0

是的。我的Word是默認RTL – user3041065

回答

1

這可能是Office Interop庫中的一個缺陷。爲了測試理論,在嘗試操作之前嘗試將線程的文化設置爲LTR語言。

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us"); 
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); 

如果設置線程文化的工作原理,可能有一種侵入性較小的方式來設置文檔的文化。例如,Excel互操作程序集提供了重寫數字分隔符的功能,如this SO question中所示。

+0

感謝您的快速回復!我已經嘗試了上面的代碼,但仍然沒有任何反應。 – user3041065

+0

你的意思是「什麼都沒有發生」或「沒有改變」? – neontapir

+0

沒變!該程序與添加上面的代碼之前一樣。 – user3041065