首页 > 解决方案 > Range.Style 因语言而异

问题描述

我刚刚做了一个宏,它根据英文版 Office 中的某些内容更改样式。

现在我打开了西班牙语版本,但它不起作用。

事实证明,.Style ="Bad"现在是.Style ="Incorrecto"等等。

如何设置适用于任何语言的样式?

有没有可以按索引处理的样式集合?

标签: excelvba

解决方案


If you are wanting to ensure consistency across multiple languages, you could add a custom style to the sheet. This custom style should not change based on the user's language.

With ActiveWorkbook.Styles.Add(Name:="Some_Name") 
 .Borders(xlTop).LineStyle = xlDouble 
 .Font.Bold = True 
 .Font.Name = "Calibri" 'This is any font name, but you might check that it is same across different user languages.
End With 
Worksheets(1).Range("A25:A30").Style = "Some_Name"

This is a workaround, but once defined it should be just as easy to use. Best of luck!


推荐阅读