Macro is a term used for batch processing. Common examples include TeX language and Microsoft's VBA (Visual Basic for Applications). They can help users automate a series of operations, improving efficiency and accuracy. By writing macros, users can simplify repetitive tasks and batch process large amounts of data when needed. Whether in document processing, data analysis or other fields, macros play an important role.
1. Office macro, translated from the English word Macro. Macro is a special function designed by Microsoft for its OFFICE software package. It is a tool designed by software designers to allow people to avoid repeating the same actions over and over again when using the software to work. It uses simple syntax to Commonly used actions are written as macros. When working, you can directly use the pre-written macros to run automatically to complete a specific task without having to repeat the same actions. The purpose is to automate some tasks in user documents.
There are macros in WORD and EXCEL in OFFICE. Word pre-defines a common template (Normal.dot) for everyone, which contains basic macros. As soon as you start Word, the Normal.dot file will automatically run. If you perform a certain task repeatedly in Word, you can use macros to automate it. Word provides two ways to create macros: the macro recorder and the Visual Basic editor. Macros combine a series of Word commands and instructions to form a command to automate task execution. By default, Word stores macros in the Normal template so that all Word documents can be used. This feature is exploited by almost all macro viruses.
2. In the C language source program, an identifier is allowed to represent a string, which is called a "macro". An identifier defined as a "macro" is called a "macro name". During compilation and preprocessing, all "macro names" that appear in the program are replaced with the strings in the macro definition. This is called "macro substitution" or "macro expansion".
Macro definition is completed by the macro definition command in the source program. Macro substitution is done automatically by the preprocessor. In C language, "macro" is divided into two types: parameterized and parameterless. The definitions and calls of these two "maros" are discussed below.
A macro in computer science is an abstraction that replaces a certain text pattern according to a series of predefined rules. The Excel office software automatically integrates the "VBA" high-level programming language, and the program compiled in this language is called a "macro". Using "VBA" requires a certain programming foundation and consumes a lot of time. Therefore, the vast majority of users only use the general tabulation function of Excel and rarely use "VBA".
The interpreter or compiler will automatically perform this pattern replacement when encountering a macro. For compiled languages, macro expansion occurs at compile time, and tools that perform macro expansion are often called macro expanders. The term macro is often used in many similar contexts, derived from the concept of macro expansion, including keyboard macros and macro languages. Most of the time, the use of the word "macro" implies the conversion of small commands or actions into a series of instructions.
The purpose of macros is to automate frequently used sequences or to achieve a more powerful abstraction - but this is often the same thing.
Computer languages such as C or assembly language have simple macro systems, which are implemented by the preprocessor of the compiler or assembler. The job of C's macro preprocessor is just simple text search and replacement. Using additional text processing languages such as M4, C programmers can get more sophisticated macros.
Lisp-like languages such as Common Lisp and Scheme have more sophisticated macro systems: Macros behave like functions that deform their own program text, and all languages can be used to express this deformation. A C macro can define a grammatical replacement, but a Lisp macro can control the calculation of a section of code.
Gains the ability to control the execution order of code (see lazy evaluation and unrestricted functions), making newly created syntax structures indistinguishable from the language's built-in syntax structures. For example, a Lisp dialect that has cond but not if can use macros to define the latter from the former. Major extensions to Lisp syntax, such as the object-oriented CLOS system, can be defined by macros.
Microsoft Word and Macro Viruses
Visual Basic for Applications (VBA) is a programming language in Microsoft Office. But according to the above definition, it is not a macro language at all. However, its functionality has evolved from and eventually replaced the macro idea of user applications, so it is widely and erroneously referred to as a macro language.
VBA has access to many operating system functions and supports automatic execution of macros when a document is opened. This makes it possible to write computer viruses in this language. In the mid-to-late 1990s, macro viruses became one of the most popular types of computer viruses. Other projects that include macro languages, such as openoffice.org, deliberately exclude some features (such as automatic execution) from their macro languages to avoid breaking programs. However, this feature is welcomed in many transactions.
In word menu
[Tools]-[Macro]-[Security] You can find relevant options to set (explained in detail in the settings, not explained)
The above is the detailed content of What is the definition of macro in Word?. For more information, please follow other related articles on the PHP Chinese website!