如何在ms字的开头运行VBA宏 [英] how to run VBA macro in the start of ms word

查看:88
本文介绍了如何在ms字的开头运行VBA宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,

我必须在VBA中开发一个宏,它应该在ms字开始时运行,并且当新文档创建或打开任何现有文档时。我的问题是无法将宏放在正确的位置。

我想写一个宏,当文档打开或创建时,它会使字体Arial成为默认值。我知道这个设施已经由微软提供,但我需要为我们的客户做这件事。

请帮助我。

问候

Dear Expert,
I have to develope a macro in VBA which should be run when the ms word start, and when new document created or open any existing document. My problem is am not able to place the macro at correct position.
I want to write a macro which will make the font "Arial" default when document will be open or created. I know this facility already given by microsoft but i need to do this for our clients.
Kindly help me.
Regards

推荐答案

您好,



根据我的知识,您需要将文档保存为启用宏的word文档扩展名。 (我正在使用2010年的单词.docm)。按Alt + F11导航到代码窗口,然后尝试以下代码保存文档。这对我有帮助。



Sub activeMacro()

Selection.Font.Name =Arial

Selection.Font.Size = 16

End Sub



谢谢。

Sriram.B
Hi,

As per my Knowledge you need save the document as Macro enabled word document extension. ( I am using word 2010 so .docm). Press Alt+F11 to navigate to code window then try this below code Save the document. This will help you I think.

Sub activeMacro()
Selection.Font.Name = "Arial"
Selection.Font.Size = 16
End Sub

Thanks.
Sriram.B


您不需要任何代码。创建新的普通模板文档并将其发送给您的客户。

模板是一种文档类型,在您打开它时会创建自己的副本。只要您启动Word,就会打开普通模板,并且包括默认样式,自动图文集,宏,工具栏以及其他用于确定文档基本外观的自定义项。



更改Normal模板(Normal.dot) [ ^ ]

更改Normal模板(Normal.dotm) [ ^ ]

将Word文档另存为模板 [< a href =http://office.microsoft.com/en-us/word-help/save-a-word-document-as-a-template-HA010030754.aspx\"target =_ blanktitle =新窗口> ^ ]



使用宏设置默认字体是个坏主意;(
You don't need any code. Create new Normal Template document and send it to your client.
A Template is a document type that creates a copy of itself when you open it. A Normal template opens whenever you start Word, and it includes default styles, AutoText, macros, toolbars, and other customizations that determine the basic look of your document.

Change the Normal template (Normal.dot) [^]
Change the Normal template (Normal.dotm )[^]
Save a Word document as a template[^]

Using macros to set default font is a... bad idea ;(


这篇关于如何在ms字的开头运行VBA宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆