首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VC >

VC.net打开dot文件有有关问题,C#代码正常,烦死了

2012-01-01 
VC.net打开dot文件有问题,C#代码正常,烦死了想打开一个dot文件,输入文字,C#代码正常,VC.net异常,困扰几天

VC.net打开dot文件有问题,C#代码正常,烦死了
想打开一个dot文件,输入文字,C#代码正常,VC.net异常,困扰几天了,烦呀...
//--------------------------------------------C#
  Word._Application oWord;
  Word._Document oDoc; 
  oWord = new Word.ApplicationClass ();
 
object oMissing = System.Reflection.Missing.Value;
  object Nothing = System.Reflection.Missing.Value;
object otemp ="e:\\hmh.dot"
  oWord.Visible = false ;
oDoc = oWord.Documents.Add(ref otemp, ref oMissing,ref oMissing, ref oMissing);
 
  object x = "name";
  Word.Bookmark bm = oDoc.Bookmarks.Item(ref x);
  bm.Range.Text = "Test_Name";//--正常,有Text属性!!!

  object fn = "e:\\a1.doc";
   
  oDoc.SaveAs(ref fn, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);
  oWord.Documents.Close(ref Nothing, ref Nothing, ref Nothing);
  oWord.Quit(ref Nothing, ref Nothing, ref Nothing);


//--------------------------------------------VC
Word:: _Application^ oWord;
Word::_Document^ oDoc; 
oWord = gcnew Word::ApplicationClass ();
 
Object^ oMissing = System::Reflection::Missing::Value;
  Object^ Nothing = System::Reflection::Missing::Value;
Object^ otemp ="e:\\hmh.dot" ;//GetDirectoryFromFile(System::Windows::Forms::Application::ExecutablePath)+@"Customers::dot"; 

oWord->Visible = true ;
oDoc = oWord->Documents->Add( otemp, oMissing, oMissing, oMissing);
System::Object^ x = "name";
Word::Bookmark^ bm = oDoc->Bookmarks->Item(x) ;
bm->Range->Text ----->没有Text属性??? 
我仔细比较了引用的Dll“Interop.Word.dll”,是一样的版本,这是为何???
恳求高手指点...

[解决办法]
try

bm->Range->SetText
[解决办法]
你試試
bm->Range.Text

热点排行