6

私はExcel VBAを初めて使用し、セルをループして値を取得するVbaコードを作成しました。その後、いくつかの処理を行い、特定の基準に一致する場合は、改行でリストに追加します。すべての行が完了するまでこれを行います。これは完全に正常に機能し、最終結果は次の画像のようになります。

ここに画像の説明を入力

問題は、フォーマットをきちんと見えるようにしたいので、テキスト間のギャップがすべての行で同じになるようにして、きちんと見えるようにする方法があります。行を追加する方法は次のとおりです。

          Dim tmpLine
          tmpLine = line & "      " & dateVal
          mainMessage = mainMessage & tmpLine & vbNewLine

それが完璧な方法かどうかはわかりませんが、それが私が知っていることです...

4

4 に答える 4

3

可能な限り完全な解決策を実装し、かなりの労力を費やしました。FmsgBox.xlsm WorkbookからclsFmsgBoxfrmFmsgBox、およびmodFmsgBoxを転送する場合、以下のコードは、この種のメッセージ ボックスを比較的簡単に管理できるようにします。上記のワークブックには、コーディング例も記載されています。

 With cFmsgBox
    .Title = "Message Box supporting formatted text. Example 1"
    .Msg = "This is the first " & _
     .b("Test ") & "message spanning over several lines and paragraphs. The default margins, spaces, and font size had been used. " & _
                   "No need to say that the form width had been adjusted manually in order to have an optimum appearance." & _
     .Lf & _
     .Lf & "The formats " & _
     .b("bold") & ", " & _
     .u("underline") & ", and " & _
     .i("italic ") & "and may be combined with any of the colours " & _
     .b(.i(.u(.red("red")))) & ", " & _
     .b(.i(.u(.blue("blue")))) & ", and " & _
     .b(.i(.u(.green("green")))) & "." & _
     .Lf & .Lf & _
           "5 different links may be included in the message text, either in the full form like " & _
     .link("www.google.com") & " or with a friendly name like " & .link("www.google.com", "google.com") & ", which masks the url behind it." & _
     .Lf & _
     .Lf & _
        "Also it shows 2 of the 6 possible reply buttons and that they may contain any text. Since the number of lines is maximized to 3 their width will be adjusted " & _
        "automatically - but will remain the same for all buttons. The string returned by the display call is identical with the string of the clicked reply button."

    .Reply1 = "Click this reply to continue with the next example"
    .Reply2 = "Click this reply to finish with the Message Box solution's features"
    .Dsply 318

    If .Reply = .Reply1 Then Example2
End With

メッセージは、書式設定されたテキスト文字列ごとに動的に作成されたラベルと、動的に作成された (最大 6 つの) コマンド ボタンを備えた専用のユーザー フォームに表示されます。書式設定されたメッセージの鍵は、太字の場合は .b("xxx")、斜体の場合は .i("xxx") などの書式プロパティです。これらはすべて .b(.i("xxx")) のようにネストできます。たとえば、斜体の太字のテキストを取得します。

あるいは、連結された文字列の代わりに、メッセージ テキストに RTF/HTML のような書式設定タグを付けて提供することもできます。これにより、開始/終了タグの文字がデフォルトで {} になりますが、<> に変更することもできます。例: 「{b}太字{/b) {i}斜体{/i}」。次のように表示されます:太字 イタリック.

于 2015-11-22T21:42:50.573 に答える