Code :
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 Microsoft.Office.Interop;
namespace WordToPdf
{
public partial class WordPDF : Form
{
public WordPDF()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//set filter
openFileDialog1.Filter = "Document Word|*.doc;*.docx";
openFileDialog1.FilterIndex = 1;
openFileDialog1.Multiselect = false;
openFileDialog1.ShowDialog();
textBox1.Text = openFileDialog1.FileName;
}
private void button2_Click(object sender, EventArgs e)
{
saveFileDialog1.Filter = "PDF Format|*.pdf";
saveFileDialog1.ShowDialog();
textBox2.Text = saveFileDialog1.FileName;
}
private void button3_Click(object sender, EventArgs e)
{
this.timer1.Start();
Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application();
wordDocument = appWord.Documents.Open(textBox1.Text);
wordDocument.ExportAsFixedFormat(textBox2.Text, WdExportFormat.wdExportFormatPDF);
}
public Microsoft.Office.Interop.Word.Document wordDocument
{
get;
set;
}
private void progressBar1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(3);
}
}
}
Comments
Post a Comment