' - I = Italics (the default is Not Italic) ' If N (=New paragraph) is specified the formatting will be applied ' indicated paragraph, the space will be added above it. ' If the space to be reduced is larger than available below the ' specified for insertion below the indicated paragraph, ' For example, 2.5 adds 2 and a half lines to the space already ' Can be positive or negative and include decimal fractions. ' - 1 = A multiple of 12 pt added above or below a paragraph. ' - C = Centre (text will be aligned at the centre) ' - R = Right (text will be aligned at the right margin)
' - L = Left (Default: text will be aligned at the left margin) ' - N = New paragraph (the text will be inserted in a new line) ' if no new line is specified the text will be added to the ' if no space is specified, no space will be added, ' if Bold isn't specified the inserted text will not be bold, ' If omitted, no setting will be applied, for example, ' can be written in any sequence, upper or lower case, ' Formatting Codes can be partially or entirely omitted, ' Either or both can be omitted but if part B is present 'Arg' is a string, consisting of two parts as follows. ' It must be provided but can be a null string. ' The two arguments are separated from each other by a comma. ' 'InsertText' requires 2 arguments as follows. TextLineCreate " Hello World", Style:="Normal", Bold:=False, FontSize:=12, LineReturn:=1 TextLineCreate "Message:", Underline:=True, LineReturn:=0 Selection.EndKey Unit:=wdStory, Extend:=wdMove ' Moves to the end of the document. Text = String(LineReturn, Chr(13)) ' Adds any desired white space Set TextRng = ActiveDocument.Range(StartIndex, EndIndex) ' Determines the range of characters that the text will occupy
StartIndex = CharCount - Len(Text) - 1 ' Determines the character index of where the Text's characters beginĮndIndex = CharCount - 1 ' Determines the character index of where the Text's characters end Sub TextLineCreate(Text As String, _ĬharCount = ' Determines how many characters are on the sheet Berikut adalah kode yang saya miliki sekarang, bersama dengan gambar apa yang terjadi pada saat eksekusi. Saya telah mencoba beberapa metode berbeda dan bahkan berkonsultasi dengan buku makro saya untuk excel yang memiliki 1 bab tentang mengotomatisasi excel. Yang perlu saya lakukan, adalah untuk dapat menghasilkan satu baris teks yang memiliki judul bagian tebal dan bergaris bawah, dan deskripsi teks normal setelahnya. Oke, saya terus mengerjakan ini, dan saya telah mempersempit masalahnya TypeParagraph ' Adds any desired white spaceīerikut ini tautan ke gambar masalahnya: īerikut ini tautan ke gambar masalah dengan karakter kembali yang divisualisasikan: NG0M8 Style = PreviousStyle ' Restores previous style configuration. Font.Bold = False ' Restores previous bold setting Font.Size = FontSize ' Sets the font size. ParagraphFormat.Alignment = wdAlignParagraphRight ParagraphFormat.Alignment = wdAlignParagraphLeft ParagraphFormat.Alignment = wdAlignParagraphCenter 'Selection.EndKey Unit:=wdStory ' Moves to the end of the document. Set PreviousStyle = Selection.Style ' Saves previous style configuration. ' Creates a Formatted String with Text 'String' Saya sudah mencoba mencari cara memecahkan pilihan Word, tetapi sejauh ini tidak berhasil.īerikut kode yang saya jalankan: Sub TextLineCreate(Text As String, Optional Style As String = "Title", Optional Bold As Boolean = True, Optional Italics As Boolean = False, Optional Underline As Boolean = False, Optional FontSize As Long = 16, Optional Alignment As String = "Center", Optional LineReturn As Long = 1) TypeParagraph, tapi saya tidak selalu ingin carriage return setelah baris teks ditulis ke dokumen. Saya sudah bisa menyelesaikan ini menggunakan. Masalah yang saya alami adalah ketika saya mengeksekusi kode di bawah ini dengan satu format, dan kemudian menjalankannya lagi menggunakan format yang berbeda, itu juga memformat ulang baris sebelumnya yang ditulis. Saya mencoba menggunakan makro untuk mempercepat beberapa kode LabVIEW yang perlu menulis laporan secara otomatis untuk klien, namun perlu diformat dengan cara tertentu.