言語:C# / Ver:2005 / プラットフォーム:Windows XP 以下の様にC#にてWordファイルを開き、他のWord文書を挿入した後に現在の総ページ数を知りたいのですがどうすればよいでしょうか。(Wordファイル保存前に) ちなみに Word2003を使用しています。 VisualStudio2005StandardEditionを使用しています
using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; using System.Drawing; using iWordS = Microsoft.Office.Interop.Word;
namespace ManualDB { static class MainP { [STAThread] static void Main() { object oMissing = System.Reflection.Missing.Value; iWordS._Application oWord = new iWordS.Application(); iWordS._Document oDoc; iWordS.Selection WordSec;
Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); object oFileName = @"C:\Test.Doc"; object oReadOnly = false; oDoc = oWord.Documents.Open(ref oFileName, ref oMissing, ref oReadOnly, 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 ); WordSec = oDoc.ActiveWindow.Selection; WordSec.InsertFile(@"C:\TestA.Doc", ref oMissing, ref oMissing, ref oMissing, ref oMissing); WordSec.InsertFile(@"C:\TestB.Doc", ref oMissing, ref oMissing, ref oMissing, ref oMissing);
Console.WriteLine("ファイル保存前に総ページ数を知りたい");
object bNoPrompt = true; oWord.Documents.Save(ref bNoPrompt, ref oMissing); oWord.Quit(ref oMissing, ref oMissing, ref oMissing); } } } |
| |