如何使用VBA以编程方式安装word字体?

问题描述:

大家好,



我正在为一些用户创建一个单词模板,我需要使用MT Extra字体,我知道这种字体很常见所有单词版本,但我需要确保它已安装,因为在单词安装时用户我选择不安装任何字体!



所以我可以添加一个在用户的机器上安装这种字体的VBA代码,无论机器的设置是什么? (32/64位或其他)。



提前谢谢。

Hi everyone,

I'm creating a word template for some users, and I need to use "MT Extra" font, which I know is common for all word versions, but I need to be sure that it's installed because at the time of word installation user my choose not to install any font!

So can I add a VBA piece of code to install this font on user's machine, whatever the setting of machine are ?? (32/64 bit or whatever).

Thanks in advance.

这是不可能的至少有两个原因...



1.必须通过Windows中的字体控制面板安装字体

It would be impossible for at least 2 reasons...

1. Font must be installed via Font Control Panel in Windows
Microsoft写道:
Microsoft wrote:

下载并安装新字体





一旦找到了要与Office程序一起使用的新字体,您需要从Internet下载该字体并通过您当前在计算机上使用的操作系统进行安装。由于字体适用于操作系统,因此不会直接将其下载到Office。 您应该使用Windows中的字体控制面板,然后该字体将自动与Office一起使用。



注意Microsoft以外的许多第三方将它们的字体打包在.zip文件中以减小文件大小并使下载速度更快。如果您下载了以.zip格式保存的字体,您可以通过双击字体图标并按照屏幕上的说明解压缩它。

Downloading and installing new fonts



Once you have found a new font that you would like to use with an Office program, you need to download the font from the Internet and install it through the operating system that you are currently using on your computer. Because fonts work with the operating system, they are not downloaded to Office directly. You should use the Font Control Panel in Windows, and then the font will work with Office automatically.

Note Many third parties outside of Microsoft package their fonts in .zip files to reduce file size and make downloading faster. If you have downloaded a font that is saved in .zip format, you can "unzip" it by double-clicking the icon for the font and following the instructions on the screen.



source :添加用于Office的新字体 [ ^ ]



2.系统安全限制(SSR)

如果用户帐户是标准的Windows帐户,用户可能有足够的权限通过控制面板更改任何内容。





您可以通过将字体从一台计算机复制到另一台计算机 [ ^ ],但......一个月重新开始我们将处理SSR(参见第2点)。



最后,您可以在文档中嵌入子集字体。请参阅: Document.SaveAs [ ^ ] - 使用 EmbedTrueTypeFonts = True

使用Office Open XML格式创建文档主题 [ ^ ]


source: Add new fonts to use with Office[^]

2. System Security Restriction (SSR)
If user account is standard windows account, user might have enough permission to change anything via Control Panel.


You can go arround with it by copying font from one computer to another one[^], but... one more time we will be dealing with SSR (see point 2).

Finally, you can embed 'subset fonts' to the document. Please see: Document.SaveAs[^] - with EmbedTrueTypeFonts = True
Creating Document Themes with the Office Open XML Formats[^]