문서를 반복하고 모든 양식 필드를 가져 와서 새 텍스트 파일에 삽입하는 방법을 알아 내려고하고 있습니다. 나는 내가 필요로하는 함수의 예제를 찾고자 노력하고 있으며, 많은 정보를 얻지는 못하고있다. 어쩌면 내가 제대로 검색하지 않을거야. 여기에 제가 지금까지 작성한 내용이 있습니다.C# Word 문서에서 FormField 가져 오기 및 텍스트 파일에 삽입
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;
using System.IO;
namespace purform
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// create instance of Word
Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
// create instance of Word document
Microsoft.Office.Interop.Word.Document oWordDoc = new Document();
object missing = System.Reflection.Missing.Value;
try
{
//declare objects
object fileName = @"C:\\path\\to\\file.doc";
object readOnly = false;
object isVisible = true;
//open word doc
oWordDoc = oWordApp.Documents.Open(ref fileName, ref missing, ref readOnly, ref readOnly,
ref missing, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing);
oWordDoc.Activate();
}
catch (Exception ex)
{
Console.WriteLine("Unable to locate and activate document file");
}
object oFormFields = fieldArray[i, 0];
oWordDoc.FormFields.get_Item(ref oFormFields).Range =
System.IO.File.WriteAllText(@"\\path\\to\\file.txt", fieldArray[]);
}
}
}
어떻게 병합 필드를 얻을 수 있습니까?
팁 주셔서 감사합니다! – user1059110