Enumerating styles
The following simple
VBA macro iterates over all styles that are found in a
workbook's .styles
collection:
option explicit
sub main() ' {
dim r as long
dim st as style
for each st in thisWorkbook.styles ' {
r = r + 1
cells(r, 1) = st.name
cells(r, 2) = st.font.name
cells(r, 2).font.name = st.font.name
cells(r, 3) = st.font.color
cells(r, 3).font.color = st.font.color
cells(r, 4) = st.interior.color
cells(r, 4).interior.color = st.interior.color
next st ' }
end sub ' }
In a workbook that has no manually added styles, it prints the predefined styles:
20% - Accent1 | |
20% - Accent2 | |
20% - Accent3 | |
20% - Accent4 | |
20% - Accent5 | |
20% - Accent6 | |
40% - Accent1 | |
40% - Accent2 | |
40% - Accent3 | |
40% - Accent4 | |
40% - Accent5 | |
40% - Accent6 | |
60% - Accent1 | |
60% - Accent2 | |
60% - Accent3 | |
60% - Accent4 | |
60% - Accent5 | |
60% - Accent6 | |
Accent1 | |
Accent2 | |
Accent3 | |
Accent4 | |
Accent5 | |
Accent6 | |
Bad | |
Calculation | |
Check Cell | |
Comma | |
Comma [0] | |
Currency | |
Currency [0] | |
Explanatory Text | |
Good | |
Heading 1 | |
Heading 2 | |
Heading 3 | |
Heading 4 | |
Input | |
Linked Cell | |
Neutral | |
Normal | |
Note | |
Output | |
Percent | |
Title | |
Total | |
Warning Text | |
As soon as a
hyperlink (using the
=hyperlink(…)
worksheet function or using the
hyperlink
object) is inserted into the workbook, there is also the style
Hyperlink that allows to customize this hyperlink. When this hyperlink is clicked, the style
Followed Hyperlink is added.