objselection.font.name更改为calibri

时间:2013-03-08 14:11:55

标签: vbscript rtf outlook-2007 word-2007 signatures

我有一个让我头痛的问题。我已经构建了一个VBScript签名创建脚本来从AD中提取用户信息并将其作为所有用户的签名应用。它工作得很漂亮,我很高兴。除了一个问题。我已经搜索过了 - 虽然我找到了someone else with the same issue - 但我找不到任何解决方案。


首先,关于脚本的一些背景知识:

根据Microsoft的文章here,脚本设置为使用以下对象配置签名。

Word.Application.EmailOptions.EmailSignature.EmailSignatureEntries

然后,在整个脚本中,我必须多次更改字体。要做到这一点,我使用这样的行:

objSelection.Font.Name = "Times New Roman"

这对我和我们的大多数用户来说都很好。但是,我的一位技术人员之前已将Word中的默认字体更改为Times New Roman。当我为他运行脚本时,应该是TNR的行显示为Calibri。当我们运行Office 2007时,Word中的原始默认字体是Calibri。我测试了在我自己的PC和另一台PC上更改默认字体,我能够两次复制问题。

我之前链接的technet海报注意到原始文档的所有字体都是正确的。只有当“EmailSignatureEntries”将其保存为RTF和HTML才能用作字体混合的签名时。

我真的很难过。任何帮助,将不胜感激! :)

1 个答案:

答案 0 :(得分:1)

我在为公司创建一个新的自动AD填充签名时偶然发现了同样的问题。 根据我在互联网上发现的内容,以及建议的是,当签名使用与Word中的相同字体(即Normal.dot(m))时,会出现问题。

例如; 我的公司希望Arial 10作为Word,Excel和Outlook中的默认字体。 所以我当然修改了所有需要的文件并安排了一个GPO来完成这个任务。 一切顺利,Word等将Arial作为默认字体。

现在,当我运行我的signature.vbs脚本时,该脚本也声明字体应该是Arial,结果总是Calibri字体奇怪。我玩了一下这个,并注意到我可以使用除Arial以外的任何其他字体,除了Arial之外它都可以使用。

这让我疯了2天然后它袭击了我; - 如果我在userprofile中放置一个临时normal.dot(m)(以Calibri作为默认字体),那么如何用VBS创建签名然后将正确的Normal.dot(m)放在配置文件中?

事实证明,这就是诀窍。 所以我拿出了Normal.dot(m)的文件放置GPO,并在我的批处理脚本中集成了临时副本,运行vbs,最终副本,这也触发了signature.vbs。

以下是我的批量代码,您可能需要根据自己的需要进行调整,但它提供了基本的想法。我已添加了备注的英文翻译,因此您不必学习荷兰语:))

希望这可以帮助您和仍在寻找解决方案的任何人

@echo off
REM Verwijder alle default word templates in het userprofile (niet meer via GPO)
REM Remove all default Word templates in the userprofile (no longer through GPO)
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Sjablonen\Normal.dotm
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Templates\Normal.dotm
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Sjablonen\NormalEmail.dotm
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Templates\NormalEmail.dotm

REM Check of het Handtekeningscript al gelopen heeft, zoja ga over tot plaatsen juiste normal.dotm
REM Check if the signaturescript already ran, if so copy the proper normal.dotm
IF EXIST %homeshare%\pvfsig.txt goto copynormal

REM Plaats een tijdelijke Normal.dotm ivm een conversie issue als je default Arial hebt (wordt Calibri)
REM Copy a temporary Normal.dotm in the profile so the conversion problem with the Default font won't occur.
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_met_calibri\Normal.dotm %userprofile%\AppData\Roaming\Microsoft\Sjablonen\Normal.dotm
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_met_calibri\Normal.dotm %userprofile%\AppData\Roaming\Microsoft\Templates\Normal.dotm
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_met_calibri\NormalEmail.dotm %userprofile%\AppData\Roaming\Microsoft\Sjablonen\NormalEmail.dotm
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_met_calibri\NormalEmail.dotm %userprofile%\AppData\Roaming\Microsoft\Templates\NormalEmail.dotm

REM Start Handtekening VBS script om de handtekening te genereren
REM Start signature VBS script to generate the signature
cscript \\pvf\netlogon\scripts\huisstijl\outlooksig_new.vbs

REM Verwijder tijdelijke Normal.dotm bestanden
REM Remove the temporary Normal.dotm files
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Sjablonen\Normal.dotm
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Templates\Normal.dotm
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Sjablonen\NormalEmail.dotm
DEL /F /Q %userprofile%\AppData\Roaming\Microsoft\Templates\NormalEmail.dotm

REM Creeer een check bestand op de Homedirectory v/d gebruiker
REM Create a checkfile in the users homedirectory
echo pvf standaard handtekening is aangemaakt > %homeshare%\pvfsig.txt

REM Kopieeren van juiste normal.dotm bestanden (met Arial)
REM Copy the proper normal.dotm files into place
:copynormal
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_pvf_huisstijl\Normal.dotm %userprofile%\AppData\Roaming\Microsoft\Sjablonen\Normal.dotm
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_pvf_huisstijl\Normal.dotm %userprofile%\AppData\Roaming\Microsoft\Templates\Normal.dotm
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_pvf_huisstijl\NormalEmail.dotm %userprofile%\AppData\Roaming\Microsoft\Sjablonen\NormalEmail.dotm
COPY /Y /Z \\pvf\netlogon\Scripts\huisstijl\normal_pvf_huisstijl\NormalEmail.dotm %userprofile%\AppData\Roaming\Microsoft\Templates\NormalEmail.dotm

:end
EXIT