0

Подскажите пожалуйста, как (c# winforms vs2010) выполнить вставку автотекста с именем "tbl" в место расположения закладки с именем "new". Автотекст присутствует в шаблоне "a3.dot", на основе которого создается новый документ word. Начало кода ниже:

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;
using System.Reflection;
private void btn1_Click(object sender, EventArgs e)
{
    Word._Application oWord = new Word.Application();
    object oMissing = System.Reflection.Missing.Value;
    object oEndOfDoc = "\\endofdoc";
    object oTemplate = @"c:\a3.dot";
    oWord.Visible = true;
    Word._Document oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing, ref oMissing, ref oMissing);
    ...вставить автотекст в закладку
}

1 ответ 1

0
Word.Paragraph oPara2;
object oRngEnd = oWord.Selection.GoTo(Word.WdGoToItem.wdGoToLine, Word.WdGoToDirection.wdGoToLast);
object oAutoText = "проба";
object objTrue = true;
Word.Template oTpl = (Word.Template)oDoc.get_AttachedTemplate();
oPara2 = oDoc.Paragraphs.Add(oRngEnd);
oPara2.Range.Select();
oTpl.AutoTextEntries.get_Item(ref oAutoText).Insert(oWord.Selection.Range, ref objTrue);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.