環境win7,office 2013,Embarcadero C++Builder 10.2,使用的
office2k的 WordApplication組件。
啥都不說上代碼:
String doc1 = "c:\\1.doc";
this->WordApplication1->Documents->Open(Variant(doc1.c_str()));
this->WordApplication1->Visible = true;
this->WordApplication1->Selection->Text=(wchar_t *) TEXT("haha");
功能:這個代碼打開1.doc檔案,輸入文字 “haha”。
問題:word內的輸入"haha"后面還輸入了許多亂碼,見下圖:

求解。
uj5u.com熱心網友回復:
修改代碼后又出問題了。String doc1 = "c:\\1.doc";
UnicodeString as="12345678900987654321";
this->WordApplication1->Documents->Open(Variant(doc1.c_str()));
this->WordApplication1->Visible = true;
this->WordApplication1->Selection->Text= as.w_str();
當輸入字符采用UnicodeString 編碼后,不會輸入亂碼,但是卻只輸出一般的字符。(圖片中的ffff是原來就有的內容。)

求正解。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/58079.html
標籤:基礎類
上一篇:3維滑鼠懸停顯示當前坐標
