Add a written macro comment using the shortcut key

Source: Internet
Author: User

To facilitate the maintenance personnel to others ,. the file header comment is indispensable for each class library file in. You can use "Ctrl + C" and "Ctrl + V" to achieve your goal, and use shortcuts to achieve your goal.

How to create a file header comment:

1. Open Vs and click "tool"> "macro"> "macro IDE (I)", that is:


2. In the macro editing window, select "samples"> "add"> "Add new project", that is:

Third: if a new item is added, select "module"> "add". You can change the name or not. That is:

Fourth: You can write comments about the file header. The Code is as follows:

Sub DocumentFileHeader()
Dim doc as document dim docname as string dim companyName as string = "upgrade 9" dim authorname as string = "Zhu Dan" dim versionnumber = "1.1" 'get the file name from the program doc = DTE. activedocument 'get the name of the current editing class docname = Doc. name' will add the focus to the DTE in the file header. activedocument. selection. startofdocument () 'Add a copyright notice DTE. activedocument. selection. TEXT = "'************************************ * ***************** "'Add the desired symbols and text DTE in the string type. activedocument. selection. newline () DTE. activedocument. selection. TEXT = "'Author:" + authorname DTE. activedocument. selection. newline () 'adds an empty row DTE. activedocument. selection. TEXT = "'file name:" + docname DTE. activedocument. selection. newline () DTE. activedocument. selection. TEXT = "'Description:" DTE. activedocument. selection. newline () DTE. activedocument. selection. TEXT = "'creation Date:" + String. format ("{0: d}", date. now) DTE. activedocument. selection. newline () DTE. activedocument. selection. TEXT = "'version:" + versionnumber DTE. activedocument. selection. newline () DTE. activedocument. selection. TEXT = "'************************************ * ******************* "DTE. activedocument. selection. newline () end sub

Don't forget to click Save. In this way, you can use the macro to write the file header comment. So how can I use the shortcut key to call the prepared comments?

Assign shortcut key:

1. Go back to Vs and click "Tools"> "options", that is:


Second: In the options window, click "keyboard", find the file header comment file you just compiled in "display command inclusion", and then in "press the shortcut key, press the shortcut key you want to give it (not enter the shortcut key ...), If your shortcut key and existing objects are used at this time, you will be prompted in the "currently used object shortcut key" item. Then, "allocate" and "OK". The operation is completed, namely:


Note:

In this way, you can use a macro to write a file header comment and assign it a shortcut key. In this way, you only need a shortcut key to solve the file header annotation problem. Note:

As long as you carefully read and learn, you can do it!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.