1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51:
| Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word._Document wordDocument = null; wordDocument = wordApplication.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
TableOfContents toc = wordDocument.TablesOfContents.Add(wordDocument.Application.Selection.Range, ref UseHeadingStyles, ref UpperHeadingLevel, ref LowerHeadingLevel, ref missing, ref missing, ref RightAlignPageNumbers, ref IncludePageNumbers, ref missing, ref UseHyperlinks, ref HidePageNumbersInWeb, ref UseOutlineLevels); wordApplication.ActiveDocument.TablesOfContents[1].TabLeader = WdTabLeader.wdTabLeaderDots; wordApplication.ActiveDocument.TablesOfContents.Format = WdTocFormat.wdTOCClassic;
object oName = "Normal.dotm"; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].NumberFormat = "%1"; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].TrailingCharacter = WdTrailingCharacter.wdTrailingTab; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].NumberStyle = WdListNumberStyle.wdListNumberStyleArabic; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].NumberPosition = 0; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].Alignment = WdListLevelAlignment.wdListLevelAlignLeft; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].TextPosition = zahl; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].ResetOnHigher = 0; wordApplication.ActiveDocument.ListTemplates.get_Item(ref oName).ListLevels[1].StartAt = 1;
headingType = WdBuiltinStyle.wdStyleHeading2; wordApplication.Selection.set_Style(ref headingType); wordApplication.Selection.Font.Name = "???"; wordApplication.Selection.Font.Size = 14; wordApplication.Selection.Font.Color = WdColor.wdColorBlack; wordApplication.Selection.TypeText(_strObjektArray[i]); wordApplication.Selection.Range.Paragraphs.OutlineLevel = WdOutlineLevel.wdOutlineLevel1; wordApplication.Selection.TypeParagraph();
toc.Update(); |