Autor Beitrag
Vitalic
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Mo 30.01.12 17:24 
Hallo,
wie bekomme ich diesen Quellcode in C# umgesetzt?

ausblenden volle Höhe Quelltext
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:
   With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
        .NumberFormat = "%1."
        .TrailingCharacter = wdTrailingTab
        .NumberStyle = wdListNumberStyleArabic
        .NumberPosition = CentimetersToPoints(0)
        .Alignment = wdListLevelAlignLeft
        .TextPosition = CentimetersToPoints(0.63)
        .TabPosition = wdUndefined
        .ResetOnHigher = 0
        .StartAt = 1
        With .Font
            .Bold = wdUndefined
            .Italic = wdUndefined
            .StrikeThrough = wdUndefined
            .Subscript = wdUndefined
            .Superscript = wdUndefined
            .Shadow = wdUndefined
            .Outline = wdUndefined
            .Emboss = wdUndefined
            .Engrave = wdUndefined
            .AllCaps = wdUndefined
            .Hidden = wdUndefined
            .Underline = wdUndefined
            .Color = wdUndefined
            .Size = wdUndefined
            .Animation = wdUndefined
            .DoubleStrikeThrough = wdUndefined
            .Name = ""
        End With
        .LinkedStyle = ""
    End With


Gruß
Vitalic
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mo 30.01.12 18:15 
ausblenden C#-Quelltext
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:
var level = ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1);
level.NumberFormat = "%1.";
level.TrailingCharacter = wdTrailingTab;
level.NumberStyle = wdListNumberStyleArabic;
level.NumberPosition = CentimetersToPoints(0);
level.Alignment = wdListLevelAlignLeft;
level.TextPosition = CentimetersToPoints(0.63);
level.TabPosition = wdUndefined;
level.ResetOnHigher = 0;
level.StartAt = 1;
level.Font.Bold = wdUndefined;
level.Font.Italic = wdUndefined;
level.Font.StrikeThrough = wdUndefined;
level.Font.Subscript = wdUndefined;
level.Font.Superscript = wdUndefined;
level.Font.Shadow = wdUndefined;
level.Font.Outline = wdUndefined;
level.Font.Emboss = wdUndefined;
level.Font.Engrave = wdUndefined;
level.Font.AllCaps = wdUndefined;
level.Font.Hidden = wdUndefined;
level.Font.Underline = wdUndefined;
level.Font.Color = wdUndefined;
level.Font.Size = wdUndefined;
level.Font.Animation = wdUndefined;
level.Font.DoubleStrikeThrough = wdUndefined;
level.Font.Name = "";
level.LinkedStyle = "";

Was aus wdUndefined werden soll, hängt von der Bibliothek ab, die du verwendest. Kannst du uns da nähere Details geben?

Grüße,
Yogu
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4799
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Mo 30.01.12 18:34 
Hallo vitalic,

das hättest du auch einfach selber mit einem freien VB.NET -> C# Converter machen können, z.B. www.developerfusion....convert/vb-to-csharp ;-)
Vitalic Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Di 31.01.12 10:49 
Hallo,

da der von euch übersetze Code bei mir nicht funktioniert, habe ich versucht diesen selber zu übersetzen.
Das Problem was ich habe, der Code funktioniert auch nicht.
Bitte um Hilfe.
ausblenden volle Höhe C#-Quelltext
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:
// Neue WordApplikation erstellen
Microsoft.Office.Interop.Word.Application wordApplication = new Microsoft.Office.Interop.Word.Application();

// Erstelle neues Worddokument
Microsoft.Office.Interop.Word._Document wordDocument = null;
// Öffne Worddokument
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);

// Inhaltsverzeichnis wird erstellt
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;


//Hier ist die Formatierung
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;

// Hier soll eine Überschrift mit Nummerierung erstellt werden
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();
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Di 31.01.12 11:16 
Zitat:
da der von euch übersetze Code bei mir nicht funktioniert, habe ich versucht diesen selber zu übersetzen.


So wie du das schreibst klingt das so so als würdest du das Forum als billige Hilfskraft mißbrauchen für Arbeiten zu denen du eigentlich keine Lust hast. Wir wollen helfen und nicht deine Job machen. Das heißt erst selbst probieren und wenn du an irgendwas hängst nachfragen.

Zitat:
Das Problem was ich habe, der Code funktioniert auch nicht.


Das Problem das ich habe, deine Problembeschreibung funktioniert nicht. Keiner hat Lust deinen Code zu scannen und dein Problem daraus zu erraten. Sag doch einfach was du für einen Fehler bekommst. Oder wenn du keine konkrete Fehlermeldung bekommst sag und was du eigentlich erwartest aber stattdessen passiert.
Vitalic Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Di 31.01.12 12:07 
user profile iconRalf Jansen hat folgendes geschrieben Zum zitierten Posting springen:

So wie du das schreibst klingt das so so als würdest du das Forum als billige Hilfskraft mißbrauchen für Arbeiten zu denen du eigentlich keine Lust hast. Wir wollen helfen und nicht deine Job machen. Das heißt erst selbst probieren und wenn du an irgendwas hängst nachfragen.

Ich kann auch den Quellcode in den Converter einfügen und dass er unbrauchbaren Code ausspuckt ist klar, daher habe ich versucht selbst den Code zu schreiben und nicht den vom Converter einfach hier einzufügen.

Zitat:

Das Problem das ich habe, deine Problembeschreibung funktioniert nicht. Keiner hat Lust deinen Code zu scannen und dein Problem daraus zu erraten. Sag doch einfach was du für einen Fehler bekommst. Oder wenn du keine konkrete Fehlermeldung bekommst sag und was du eigentlich erwartest aber stattdessen passiert


Das Problem liegt an der Nummerierung der einzelnen Überschriften, denn diese werden nicht angezeigt.