this is my code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Word;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
object missing = System.Reflection.Missing.Value;
object fileName = @"C:\b.docx";
Microsoft.Office.Interop.Word.Application WordApp = new Microsoft.Office.Interop.Word.Application();
Document adoc = WordApp.Documents.Open(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);
Range rngPic = adoc.Tables[1].Cell(1, 2).Range;
rngPic.InsertFile(@"C:\a.docx", ref missing, ref missing, ref missing, ref missing);
WordApp.Visible = true;
}
}
}
what my expectation is b.docx
should contain the file a.docx
rather the content of a.docx
was added to the b.docx
.
In clear to say i need to insert a.docx into b.docx using c# programmatically as we do insert object in word.
i need to add the whole file into the word document. not content of the file help me!!!
correction , suggestions, new codes are most welcomed.
please help me.