2

我正在尝试在 Word 文档(Word 2007)中更改项目符号的样式......我目前放置了一个项目符号,它以一个圆圈的形式出现。我希望它是一个正方形...这是我应用子弹的代码...

    public void ToggleBullets(bool bulletsOn)
{
    Microsoft.Office.Interop.Word.Application wd;
    Object _oMissing = Type.Missing;
    Object _numberType = WdNumberType.wdNumberListNum;
    if (bulletsOn)
    {
        wd.Selection.Range.ListFormat.ApplyBulletDefault(ref _oMissing);
    }
    else
    {
        wd.Selection.Range.ListFormat.RemoveNumbers(ref _numberType);
    }
}

有任何想法吗?如果您需要更多详细信息,请告诉我

4

1 回答 1

1

我使用适用于 Microsoft Office 的 Open XML SDK 2.0 生产力工具:http: //www.microsoft.com/downloads/en/details.aspx? FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&displaylang=en

当我想做这些事情的时候。只需启动生产力工具,加载包含您想要的内容的 .docx,然后让该工具为您生成代码。

我刚刚做了一个例子,这是它生成的代码:

using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml;
....
    public Paragraph GenerateParagraph()
    {
        Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "00EA7FFB", RsidParagraphProperties = "00EA7FFB", RsidRunAdditionDefault = "00EA7FFB" };

        ParagraphProperties paragraphProperties1 = new ParagraphProperties();
        ParagraphStyleId paragraphStyleId1 = new ParagraphStyleId(){ Val = "ListParagraph" };

        NumberingProperties numberingProperties1 = new NumberingProperties();
        NumberingLevelReference numberingLevelReference1 = new NumberingLevelReference(){ Val = 0 };
        NumberingId numberingId1 = new NumberingId(){ Val = 2 };

        numberingProperties1.Append(numberingLevelReference1);
        numberingProperties1.Append(numberingId1);

        paragraphProperties1.Append(paragraphStyleId1);
        paragraphProperties1.Append(numberingProperties1);

        Run run1 = new Run();
        Text text1 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
        text1.Text = "Item ";

        run1.Append(text1);

        paragraph1.Append(paragraphProperties1);
        paragraph1.Append(run1);
        return paragraph1;
    }

这是使用 OpenXml 标头,而不是专门使用 Word

于 2011-04-12T16:30:10.053 回答