83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
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 System.IO;
|
|
using LBWordLibrary;
|
|
|
|
namespace ImportWordContent
|
|
{
|
|
public partial class frmImportWordContent : Form
|
|
{
|
|
public frmImportWordContent()
|
|
{
|
|
InitializeComponent();
|
|
btnNext.Enabled = false;
|
|
btnPage.Enabled = false;
|
|
btnPrevious.Enabled = false;
|
|
}
|
|
private void ofd_FileOk(object sender, CancelEventArgs e)
|
|
{
|
|
tbWordFile.Text = ofd.FileName;
|
|
}
|
|
private void btnBrowse_Click(object sender, EventArgs e)
|
|
{
|
|
// if we have a word doc open, then close it and reset WordApp
|
|
if (_WordApp != null)
|
|
{
|
|
_WordApp.Quit(false);
|
|
_WordApp = null;
|
|
}
|
|
ofd.ShowDialog();
|
|
}
|
|
LBApplicationClass _WordApp;
|
|
private void btnOpen_Click(object sender, EventArgs e)
|
|
{
|
|
if (!File.Exists(tbWordFile.Text))
|
|
{
|
|
MessageBox.Show(string.Format("{0}", tbWordFile.Text), "File Does Not Exist", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
btnNext.Enabled = false;
|
|
btnPage.Enabled = false;
|
|
btnPrevious.Enabled = false;
|
|
return;
|
|
}
|
|
_WordApp = new LBApplicationClass();
|
|
_WordApp.Documents.Open(tbWordFile.Text);
|
|
_WordApp.Visible = true;
|
|
btnNext.Enabled = true;
|
|
btnPage.Enabled = true;
|
|
btnPrevious.Enabled = true;
|
|
}
|
|
|
|
private void btnNext_Click(object sender, EventArgs e)
|
|
{
|
|
_WordApp.Selection.MoveDown(LBWdUnits.wdScreen, 1, 0);
|
|
}
|
|
|
|
private void btnParagraph_Click(object sender, EventArgs e)
|
|
{
|
|
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 0);
|
|
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1);
|
|
tbParagraph.Text = _WordApp.Selection.Text;
|
|
tbStyle.Text = _WordApp.Selection.Style.NameLocal;
|
|
tbLevel.Text = _WordApp.Selection.Style.ListLevelNumber.ToString();
|
|
//_WordApp.Selection.Copy();
|
|
Clipboard.SetText(tbParagraph.Text);
|
|
}
|
|
|
|
private void btnPrevious_Click(object sender, EventArgs e)
|
|
{
|
|
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 0);
|
|
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 1);
|
|
tbParagraph.Text = _WordApp.Selection.Text;
|
|
tbStyle.Text = _WordApp.Selection.Style.NameLocal;
|
|
tbLevel.Text = _WordApp.Selection.Style.ListLevelNumber.ToString();
|
|
}
|
|
}
|
|
}
|