1
我正在使用Excel 2007,並試圖編寫將複製單元格註釋(包括格式)的VBA子例程。單元格註釋可以包含基本的文本格式(例如,粗體等樣式),我可以成功複製文本,但無法找到一種方式來使用它的格式。VBA Excel複製註釋包括格式化
我希望我可以簡單地定義一個註釋對象,然後將其設置,但不走:
Sub TestCommentCopy()
Dim r As Range
Dim c As Comment
Set r = Selection
If (Not r.Areas(1).Comment Is Nothing) Then
Set c = r.Areas(1).Comment
End If
'Set r(1, 2).Comment = c ' Object error
' r(1, 2).Comment = c 'Object error
' Set r(1,2).Comment = c ' Object error
r(1, 2).ClearComments ' Works
' r(1, 2).AddComment c 'Does not work - requires text only
r(1, 2).AddComment c.Text 'Works, but only get plain text, no formatting
End Sub
有沒有在Excel的方式複製到另一個細胞的評論,包括格式化,不只是文本?
阿感謝Gary的學生 - 我可以使用PasteSpecial方法與xlPasteComments再次得到整個事情(價值和格式)的副本...謝謝。不知道在我的代碼中使用該方法是無效的還是微軟對於對象模型的弱點,但無論如何,它都不起作用。 – Pete855217