this is the code I'm currently working / using:
- Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using Novacode;
using System.Diagnostics;
using System.IO;
using Spire.Doc;
using Spire.Doc.Documents;
namespace copy_form_fiel_to_file
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//teller
int teller = 0;
//file paths
string een = "C:\\Users\\Sebastiaan.EXIT-REIZEN\\Desktop\\test map\\1.docx";
string twee = "C:\\Users\\Sebastiaan.EXIT-REIZEN\\Desktop\\test map\\2.docx";
string drie = "C:\\Users\\Sebastiaan.EXIT-REIZEN\\Desktop\\test map\\3.docx";
//switch verwijzingen
string doc1;
string doc2;
string doc3;
private void btn_klaar_Click_1(object sender, EventArgs e)
{
Spire.Doc.Document DocOne = new Spire.Doc.Document();
DocOne.LoadFromFile(doc1, FileFormat.Docx);
Spire.Doc.Document DocTwo = new Spire.Doc.Document();
DocTwo.LoadFromFile(doc2, FileFormat.Docx);
Spire.Doc.Document Docthree = new Spire.Doc.Document();
Docthree.LoadFromFile(doc3, FileFormat.Docx);
//Merge
foreach (Spire.Doc.Section sec in DocTwo.Sections)
{
DocOne.Sections.Add(sec.Clone());
}
//Merge
foreach (Spire.Doc.Section sec in Docthree.Sections)
{
DocOne.Sections.Add(sec.Clone());
}
//save and launch
DocOne.SaveToFile(@"C:\Users\Sebastiaan.EXIT-REIZEN\Desktop\test map/5.docx", FileFormat.Docx);
System.Diagnostics.Process.Start(@"C:\Users\Sebastiaan.EXIT-REIZEN\Desktop\test map/5.docx");
}
private void btn_document1_Click(object sender, EventArgs e)
{
teller = +1;
switch (teller)
{
case 1:
doc1 = een;
break;
case 2:
doc2 = een;
break;
case 3:
doc3 = een;
break;
}
}
private void btn_document2_Click(object sender, EventArgs e)
{
teller = +1;
switch (teller)
{
case 1:
doc1 = twee;
break;
case 2:
doc2 = twee;
break;
case 3:
doc3 = twee;
break;
}
}
private void btn_document3_Click(object sender, EventArgs e)
{
teller = +1;
switch (teller)
{
case 1:
doc1 = drie;
break;
case 2:
doc2 = drie;
break;
case 3:
doc3 = drie;
break;
}
}
}
}