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 Productivity Tool を使用しています

こういうことをしたいとき。生産性向上ツールを起動し、必要なものを含む .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 に答える