Jag har plockat ihopp lite som jag har hittat.Öppna word via C#
Mitt problem (jag tror att det är det enda) jag får inte upp dokumentet(word öppnas inte)
Vad missar jag?
<code>
object fileName = "E:\\C#\\SAW\\SAW\\Report\\Just_As_I_Feel1.dot";
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
try
{
Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing,ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref isVisible,ref missing,ref missing,ref missing);
object oBookMark2 = "Text2";
oWordDoc.Bookmarks.Item(ref oBookMark2).Range.Text = textBoxFirma.Text ;
object oBookMark3 = "Text3";
oWordDoc.Bookmarks.Item(ref oBookMark3).Range.Text = textBoxNamn.Text ;
object oBookMark4 = "Text4";
oWordDoc.Bookmarks.Item(ref oBookMark4).Range.Text = textBoxBox.Text ;
object oBookMark5 = "Text5";
oWordDoc.Bookmarks.Item(ref oBookMark5).Range.Text = textBoxAdress.Text ;
object oBookMark6 = "Text6";
oWordDoc.Bookmarks.Item(ref oBookMark6).Range.Text = textBoxPostOrt.Text ;
oWordDoc.Activate();
}
catch(Exception fel)
{
MessageBox.Show(fel.Message.ToString());
}
</code>
Tacksam för hjälp