Hello ,
I'm trying to make an infopath form that makes 3 word documents when you push a button. The word document contains values that are filled in into the infopath document.
When i run the infopath document with infopath himself it works.
But when i run the infopath document in my sharepoint, he will only open word on the background and then there is nothing happening only that i got the message "sending data to the server" .
so i got 2 questions
1. Is it possible to make word documents with infopath that is web browser unabled ?
2. Is there something wrong in my code ?
Classe Word.cs
class Word
{
public string auteurWaarde;
public object sjabloon;
public object Zichtbaar;
public Type typeIngebouwdeEigenschappen;
public object Documenteigenschappen;
public object fileNaam;
public Document adoc;
public ApplicationClass Wordapp;
object missing = System.Reflection.Missing.Value;
public void openWord()
{
this.Wordapp = new ApplicationClass();
this.adoc = this.Wordapp.Documents.Add(ref missing, ref missing, ref missing, ref this.Zichtbaar);
this.Wordapp.Visible = true;
this.Documenteigenschappen = adoc.BuiltInDocumentProperties;
this.typeIngebouwdeEigenschappen = Documenteigenschappen.GetType();
}
public void setEigenschappen()
{
string strIndex = "Author";
object oDocAuthorProp = typeIngebouwdeEigenschappen.InvokeMember("Item",
BindingFlags.Default |
BindingFlags.GetProperty,
null, this.Documenteigenschappen,
new object[] { strIndex });
Type typeDocAuthorProp = oDocAuthorProp.GetType();
typeDocAuthorProp.InvokeMember("Item",
BindingFlags.Default |
BindingFlags.SetProperty,
null, this.Documenteigenschappen,
new object[] { strIndex, this.auteurWaarde });
}
public void opslaan()
{
object fileName = this.fileNaam;
this.adoc.SaveAs(ref fileName, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing);
}
public void Close()
{
this.Wordapp.Quit(ref missing, ref missing, ref missing);
}
in FormCode.cs
public void btnRaamovereenkomst_Clicked(object sender, ClickedEventArgs e)
{
// Write your code here.
//De classe Word aanroepen
Word word = new Word();
//Sjabloon laden
//Word openen
word.openWord();
word.Zichtbaar= true;
//Sjabloon meegeven
word.sjabloon = null;
// Waarde van de eigenschappen meegeven
word.auteurWaarde = "Piejtejantje";
// De eigenschappen wijzigen
word.setEigenschappen();
//Het document een naam geven
word.fileNaam = @"http://server/sites/Contracten/Raamovereenkomst/hoi.doc" ;
//Het document opslaan
word.opslaan();
//Word weer afsluiten
word.Close();
XPathNavigator linkRaamovereenkomst = MainDataSource.CreateNavigator().SelectSingleNode(
"/my:mijnVelden/my:urlRaamovereenkomst", NamespaceManager);
linkRaamovereenkomst.SetValue(word.fileNaam.ToString());
XPathNavigator cbxURLRaamovereenkomst = MainDataSource.CreateNavigator().SelectSingleNode(
"/my:mijnVelden/my:cbxURLRaamovereenkomst", NamespaceManager);
cbxURLRaamovereenkomst.SetValue("Ingeschakeld");
}