This is my Code for creating duplicate file
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void File_Click(object sender, EventArgs e)
{
this.openFileDialog1.ShowDialog();
this.textBox1.Text = this.openFileDialog1.FileName;
}
private void Submit_Click(object sender, EventArgs e)
{
//static void Main(string[] args)
{
// Initialize a bogus parameter for arguments we don't care about
object oMissing = System.Reflection.Missing.Value;
// Set the paths for the old and new documents (edit as needed)
object oldDocPath = (object)@"c:\Word.doc";
object newDocPath = (object)@"c:\New Word.doc";
// Get a Word application
Word.Application app = new Word.Application();
// Open the existing document
Word.Document oldDoc = app.Documents.Open(ref oldDocPath,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
// For hide selected text
Word.Selection.Font.Hidden == true;
// SaveAs
app.ActiveDocument.SaveAs(ref newDocPath,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
// Close the document and quit the application
oldDoc.Close(ref oMissing, ref oMissing, ref oMissing);
app.Quit(ref oMissing, ref oMissing, ref oMissing);
}
}
}
}
Deepakkumar G.
Gudevg, if this helps please login to Mark As Answer. | Alert Moderator