如何使用VBA从Excel中的单元格返回所有格式?

时间:2023-02-09 20:26:10

How can I use VBA to return all of the formatting information about a cell in Excel. For example:

如何使用VBA返回有关Excel中单元格的所有格式设置信息。例如:

如何使用VBA从Excel中的单元格返回所有格式?

I need to know which text is purple, which is green, and which is struck through. Range("B2").Value only returns the plain text. I need the formatting as well.

我需要知道哪个文字是紫色的,哪个是绿色的,哪个文字是通过的。范围(“B2”)。值仅返回纯文本。我也需要格式化。

1 个解决方案

#1


1  

your best bet is probably to use the Intellisense to explore all of the values that are available to you. You can finish off the code snippet below with things like .Color, .Strikethrough, .Bold, etc, and have them print to the immediate window. (Ctrl+G displays the immediate window if you don't currently have it displayed)

您最好的选择可能是使用Intellisense来探索您可以使用的所有值。您可以使用.Color,.Strikethrough,.Bold等内容完成下面的代码片段,并将它们打印到即时窗口。 (如果您当前没有显示,则Ctrl + G显示即时窗口)

Sub test()
debug.Print Range("B1").Font 'finish this line with any of the IntelliSense options to learn things about the text
End Sub

You can also take a look at the properties listed on the MDSN site for the font object

您还可以查看MDSN站点上列出的字体对象属性

#1


1  

your best bet is probably to use the Intellisense to explore all of the values that are available to you. You can finish off the code snippet below with things like .Color, .Strikethrough, .Bold, etc, and have them print to the immediate window. (Ctrl+G displays the immediate window if you don't currently have it displayed)

您最好的选择可能是使用Intellisense来探索您可以使用的所有值。您可以使用.Color,.Strikethrough,.Bold等内容完成下面的代码片段,并将它们打印到即时窗口。 (如果您当前没有显示,则Ctrl + G显示即时窗口)

Sub test()
debug.Print Range("B1").Font 'finish this line with any of the IntelliSense options to learn things about the text
End Sub

You can also take a look at the properties listed on the MDSN site for the font object

您还可以查看MDSN站点上列出的字体对象属性