2011-06-23 15 views
1

Excel VBAでは、各単語の形式とともにセルのテキストを取得する必要があります。たとえば、セルA1の値は「サンプルテキスト」です。 Range( "A1")。Valueプロパティはプレーンテキスト(つまり「サンプルテキスト」)のみを返します。私が欲しいのは、 "< i>サンプル</i> < b>テキスト</b>"のようなものを私に与えるオブジェクトです。 Excel DOM内のそのオブジェクトは何ですか?in excel VBA、セル内のテキストの形式を取得する方法

答えて

2

あなたはCharactersFont、一つ一つを調べることによって、そう、それに応じて出力にタグをフォーマットオープニング/クロージングすることができます

dim i as long 
for i=1 to activecell.characters.count 
    with activecell.characters(i,1).font 
    if .bold then 
     'open <b>, if not already opened 
    else 
     'close <b>, if not already closed 
    end if 

    if .italic then 
     'open <i>, if not already opened 
    else 
     'close <i>, if not already closed 
    end if 

    ' etc 
    end with 
next 
関連する問題