0
私は任意の単語自動化を試みてから長い時間がかかりましたが、長い話は短いので、リストを含む作業文書を作成する必要があります。最初のレベルは数字で、2番目は文字で、基本的にはデフォルトの番号形式を模倣していますが、それは分かりません。VBOME MS-WORD数字インデント文字列
私がこれまでに持っているコードは、字下げの数値パターンをそのまま続けています。
ここに私が今までに持っているコードと、必要なもののスクリーンキャプチャがあります。おかげ
Public NotInheritable Class Utilities
Public Shared Sub CreateDocument()
'Local Variable Declaration
Dim application As New Microsoft.Office.Interop.Word.Application
Dim document As Microsoft.Office.Interop.Word.Document
Dim range As Microsoft.Office.Interop.Word.Range
application.Visible = True
'Add a new document
document = application.Documents.Add()
'Add Header and Footer
For Each Item As Microsoft.Office.Interop.Word.Section In document.Sections
'Header
Dim header As Microsoft.Office.Interop.Word.Range = Item.Headers(Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
header.Fields.Add(header, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage)
header.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter
header.Text = "Header"
header.Font.Name = "Arial"
header.Font.Size = 10.0
header.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorRed
'Footer
Dim footer As Microsoft.Office.Interop.Word.Range = Item.Footers(Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
footer.Fields.Add(footer, Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage)
footer.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter
footer.Text = "Footer"
footer.Font.Name = "Arial"
footer.Font.Size = 10.0
footer.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorRed
Next
'Setup Default Range
range = document.Range()
range.Style = document.Styles("No Spacing")
range.Font.Name = "Arial"
range.Font.Size = 10.0
range.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorBlack
range.Text = "Line 1" & vbCrLf
range.Text &= "Line 2" & vbCrLf & vbCrLf
Dim paragraph As Microsoft.Office.Interop.Word.Paragraph = range.Paragraphs.Add
paragraph.Range.Text = "First Numbered Line:"
paragraph.Range.ListFormat.ApplyNumberDefault(Microsoft.Office.Interop.Word.WdDefaultListBehavior.wdWord10ListBehavior)
paragraph.Outdent()
Dim list = paragraph.Range.ListFormat.ListTemplate.ListLevels(1).NumberStyle = Microsoft.Office.Interop.Word.WdListNumberStyle.wdListNumberStyleLowercaseLetter
paragraph.Range.Paragraphs.Add()
paragraph.Range.Paragraphs(1).Range.Text = "Second Character Line"
paragraph.Range.Paragraphs(1).Range.ListFormat.ApplyListTemplate(document.ListTemplates(1), True, list)
paragraph.Range.Paragraphs(1).Indent()
paragraph.Range.InsertParagraphAfter()
End Sub
エンドクラス
Wordでマクロを記録し、生成されたコードを確認する方が簡単です(これは、私があなたに答えを与えるために行うものです)。これはリストのプロパティの1つですが、今はそれを覚えていません。 – Slai