VB Schriftgrösse in MS Word verändern

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 7 Antworten in diesem Thema. Der letzte Beitrag () ist von petaod.

    VB Schriftgrösse in MS Word verändern

    Hallo Zusammen,
    ich beschäftige mich mit der Einbindung mit MS Word. Nun die Basic hab ich ja schon , aber ich möchte die Shriftgrösse und Format unterschiedlich haben.

    Das ist mein Basic Code:

    VB.NET-Quellcode

    1. Imports Excel = Microsoft.Office.Interop.Excel
    2. Imports Word = Microsoft.Office.Interop.Word
    3. Public Class Form1
    4. Dim ObjWord As Word.Application
    5. Dim ObjDoc As Word.Document
    6. Dim ObjExcel As Excel.Application
    7. Dim ObjXlt As Excel.Workbook
    8. Dim ObjPara As Word.Paragraph
    9. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    10. ObjWord = CreateObject("Word.Application")
    11. ObjWord.Visible = True
    12. ObjWord.WindowState = Word.WdWindowState.wdWindowStateNormal
    13. ObjDoc = ObjWord.Documents.Add
    14. ObjPara = objDoc.Paragraphs.Add()
    15. ObjPara.Range.Text = "Test"
    16. ObjPara.Range.InsertParagraphAfter()
    17. End Sub
    18. End Class
    Danke für die Hilfe , wenn es jetzt auch spät erst ist.
    nun hab ich noch zwei weitere fragen , denke eine kann ich hier noch platzeieren:
    ich habe soweit wie gesagt alles , jetzt möchste ich es zentrieren, den text. und bin MSDN entsprechend wie google mir geholfen hat auch nachgegangen aber irgendwie will es noch nicht :

    VB.NET-Quellcode

    1. Imports Excel = Microsoft.Office.Interop.Excel
    2. Imports Word = Microsoft.Office.Interop.Word
    3. Public Class Form1
    4. Dim ObjWord As Word.Application
    5. Dim ObjDoc As Word.Document
    6. Dim ObjExcel As Excel.Application
    7. Dim ObjXlt As Excel.Workbook
    8. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    9. ObjWord = CreateObject("Word.Application")
    10. ObjWord.Visible = True
    11. ObjWord.WindowState = Word.WdWindowState.wdWindowStateNormal
    12. ObjDoc = ObjWord.Documents.Add
    13. ObjPara = ObjDoc.Paragraphs.Add
    14. ObjWord.Selection.Font.Size = 24
    15. ObjWord.Selection.Font.Name = "Arial"
    16. ObjWord.Selection.FormattedText.Font.w
    17. ObjWord.Range.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
    18. ObjPara.Range.Text = "Test"
    19. ObjPara.Range.InsertParagraphAfter()
    20. End Sub
    21. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    22. ObjDoc = ObjWord.Documents.Add
    23. ObjPara = ObjDoc.Paragraphs.Add()
    24. ObjWord.Selection.Font.Size = 24
    25. ObjPara.Range.Text = "Test"
    26. ObjPara.Range.InsertParagraphAfter()
    27. End Sub
    28. End Class


    vieleicht kann mir da jemand ein tipp geben ?

    TheDoctorWho schrieb:

    ObjWord.Range.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter

    Wieso hier plötzlich Range, während du alle anderen Formatierungen auf Selection anwendest?

    So geht's:
    msdn.microsoft.com/en-us/vba/w…graphformat-property-word
    --
    If Not Program.isWorking Then Code.Debug Else Code.DoNotTouch
    --