- Enable or disable macros in Office files
- Enable macros when the Message Bar appears
- Enable macros just for the current session
- Change macro settings in the Trust Center
- How do I create macros?
- To record two or more events at the same time
- To edit an existing macro
- To play a macro
- To cancel a macro during playback
- To enable Macro Repeat (play a macro repeatedly)
- To toggle a repeating macro
- Включение и отключение макросов в файлах Office
- Включение макросов при появлении панели сообщений
- Включить макрос только для текущего сеанса
- Изменение параметров макросов в центре управления безопасностью
Enable or disable macros in Office files
A macro is a series of commands that you can use to automate a repeated task, and can be run when you have to perform the task. This article has information about the risks involved when you work with macros, and you can learn about how to enable or disable macros in the Trust Center.
Warning: Never enable macros in an Office file unless you’re sure what those macros do. Unexpected macros can pose a significant security risk. You don’t have to enable macros to see or edit the file; only if you want the functionality provided by the macro.
If you’re looking for information on creating macros please see Quick start: Create a macro.
If you’re looking for information on using macros on a machine running Windows S see Block suspicious macros in Office on Windows 10 S.
Macros automate frequently used tasks to save time on keystrokes and mouse actions. Many were created by using Visual Basic for Applications (VBA) and are written by software developers. However, some macros can pose a potential security risk. Macros are often used by people with malicious intent to quietly install malware, such as a virus, on your computer or into your organization’s network.
Enable macros when the Message Bar appears
When you open a file that has macros, the yellow message bar appears with a shield icon and the Enable Content button. If you know the macro, or macros, are from a reliable source, use the following instructions:
On the Message Bar, click Enable Content.
The file opens and is a trusted document.
The following image is an example of the Message Bar when macros are in the file.
Enable macros just for the current session
Use the following instructions to enable macros for the duration that the file is open. When you close the file, and then reopen it, the warning appears again.
Click the File tab.
In the Security Warning area, click Enable Content.
Select Advanced Options.
In the Microsoft Office Security Options dialog box, click Enable content for this session for each macro.
Change macro settings in the Trust Center
Macro settings are located in the Trust Center. However, if you work in an organization, the system administrator might have changed the default settings to prevent anyone from changing settings.
Important: When you change your macro settings in the Trust Center, they are changed only for the Office program that you are currently using. The macro settings are not changed for all your Office programs.
Click the File tab.
Click Trust Center, and then click Trust Center Settings.
In the Trust Center, click Macro Settings.
Make the selections that you want, then click OK.
Note: The options are slightly different in Excel, we’ll call those out as we go.
Disable all macros without notification Macros and security alerts about macros are disabled.
In Excel this option is Disable VBA macros without notification and it only applies to VBA macros.
Disable all macros with notification Macros are disabled, but security alerts appear if there are macros present. Enable macros on a case-by-case basis.
In Excel this option is Disable VBA macros with notification and it only applies to VBA macros.
Disable all macros except digitally signed macros Macros are disabled, and security alerts appear if there are unsigned macros present. However, if the macro is digitally signed by a trusted publisher, the macro just runs. If the macro is signed by a publisher you haven’t trusted yet, you are given the opportunity to enable the signed macro and trust the publisher.
In Excel this option is Disable VBA macros except digitally signed macros and it only applies to VBA macros.
Enable all macros (not recommended, potentially dangerous code can run) All macros run without confirmation. This setting makes your computer vulnerable to potentially malicious code.
In Excel this option is Enable VBA macros (not recommended, potentially dangerous code can run) and it only applies to VBA macros.
Excel also has a checkbox for Enable Excel 4.0 macros when VBA macros are enabled. If you select this checkbox all of the above settings for VBA macros will also apply to Excel 4.0 (XLM) macros.
If this checkbox is not selected XLM macros are disabled without notification.
Trust access to the VBA project object model Disallow or allow programmatic access to the Visual Basic for Applications (VBA) object model from an automation client. This security option is for code written to automate an Office program and manipulate the VBA environment and object model. It is a per-user and per-application setting, and denies access by default, hindering unauthorized programs from building harmful self-replicating code. For automation clients to access the VBA object model, the user running the code must grant access. To turn on access, select the check box.
Note: Microsoft Publisher and Microsoft Access have no Trust access to the VBA project model object option.
How do I create macros?
Macros are sequences of events (such as keystrokes, mouse clicks, and delays) that can be played back to help with repetitive tasks. They can also be used to replay sequences that are long or difficult to run. You can assign a macro recorded in Microsoft Mouse and Keyboard Center to a key or a mouse button. You can also use the Macro Repeat feature to play and repeat a macro continuously, and then stop it at any time.
Microsoft Mouse and Keyboard Center macros use a .mhm extension and are saved as individual files in your default Documents\Microsoft Hardware\Macros subfolder. Macros recorded in keyboard and mouse are interchangeable. You can run them or edit them from either program.
Caution: Do not save passwords or other sensitive information in macros.
Using the mouse that you want to configure, start Microsoft Mouse and Keyboard Center.
In the list under the button that you want to reassign, select Macro.
Click Create a new Macro.
An empty macro is created and added to the macro list.
In the Name box, type the name of the new macro.
Click in Editor, and enter your macro.
You can record events such as keystrokes, mouse clicks, and delays between actions. You cannot capture mouse movement or actions performed through macros assigned to reassignable keys.
In the Available Macros list, make sure that the new macro is selected.
To record two or more events at the same time
Enter the first event (for example: press the SHIFT key).
Right-click the selected event and then select Split. The event will split into three separate events: a button press-and-hold, a time delay, and a button release.
Click between the two separate events (either before or after the delay).
Enter the second event (for example: Mouse Button 1).
To edit an existing macro
Using the mouse that you want to configure, start Microsoft Mouse and Keyboard Center.
In the list under the button that you want to reassign, select Macro.
From the Available Macros list, select the macro you want to edit.
Click in Editor and edit the macro or enter new events.
To play a macro
Click the button assigned to the macro.
To cancel a macro during playback
Click the button assigned to the macro again, or start another macro
To enable Macro Repeat (play a macro repeatedly)
In the Macro Editor, select a macro from the Available Macros.
Click Edit Macro icon
Turn on the Repeat.
Notes: Macro Repeat does not support switching applications. For example, if you open your Web browser while a macro is repeating in a game, the macro stops repeating. Likewise, if you include a command in a macro to switch to a different application, Macro Repeat does not take effect, and the macro runs once only.
If you press a button assigned to start a repeating macro and then press a button assigned to a different macro, the repeating macro stops.
A repeating macro does not include a time delay at the end of a sequence. If you want to add a delay, you can add one in The Editor box.
To toggle a repeating macro
After you enable Macro Repeat for a macro, press the key assigned to the macro to start it.
Press the button again to stop the macro from repeating.
Or, to stop the repeating macro and start another macro, press the key assigned to the other macro.
Включение и отключение макросов в файлах Office
Макрос представляет собой набор команд, с помощью которых можно автоматизировать выполнение повторяющейся задачи. В этой статье описаны риски, связанные с использованием макросов, и приведены инструкции по включению и отключению макросов в центре управления безопасностью.
Предупреждение: Никогда не в enable macros in an Office file unless you’re sure what those macros do. Неожиданные макросы могут представлять серьезную угрозу безопасности. Для этого не нужно, чтобы макрос мог видеть или редактировать файл. только в том случае, если вам нужны функции, предоставляемые макросом.
Сведения о создании макросов см. в статье Краткое руководство: создание макроса.
Если вы ищете сведения об использовании макроса на компьютере с Windows S, см. «Блокировать подозрительные макросы» в Office в Windows 10 S.
Макросы служат для автоматизации часто выполняемых задач, что позволяет сэкономить время за счет сокращения объема работы с клавиатурой и мышью. Многие из них созданы с использованием языка Visual Basic для приложений (VBA). Однако некоторые макросы представляют угрозу безопасности. Макрос часто используется злоумышленниками для тихой установки вредоносных программ, например вирусов, на компьютере или в сети организации.
Включение макросов при появлении панели сообщений
При открытии файла, содержащего макросы, появляется желтая панель сообщений со значком щита и кнопкой Включить содержимое. Если известно, что макрос поступил из надежного источника, воспользуйтесь приведенными ниже инструкциями.
В области Панель сообщений нажмите кнопку Включить содержимое.
Файл откроется и будет надежным документом.
На рисунке ниже показана панель сообщений, когда в файле есть макросы.
Включить макрос только для текущего сеанса
Выполнив приведенные ниже инструкции, можно включить макросы на то время, пока открыт файл. Если закрыть файл и открыть его снова, предупреждение появится опять.
Откройте вкладку Файл.
В области Предупреждение системы безопасности нажмите кнопку Включить содержимое.
Выберите элемент Дополнительные параметры .
В диалоговом окне Параметры безопасности Microsoft Office выберите команду Включить содержимое для этого сеанса для каждого макроса.
Нажмите кнопку ОК.
Изменение параметров макросов в центре управления безопасностью
Параметры макросов доступны в центре управления безопасностью. Однако администратор организации может изменить настройки по умолчанию, чтобы запретить изменение каких-либо параметров.
Важно: При изменении параметров макроса в центре управления доверием они изменяются только для используемого в данный момент программы Office. Параметры макроса не меняются во всех программах Office.
Откройте вкладку Файл.
Затем выберите пункты Центр управления безопасностью и Параметры центра управления безопасностью.
В центре управления безопасностью щелкните элемент Параметры макросов.
Выберите нужные вам решения и нажмите кнопку «ОК».
Примечание: Параметры в Excel немного отличаются, поэтому мы будем звонить на них по мере их вызова.
Отключить все макросы без уведомления. Этот параметр отключает макросы и связанные с ними оповещения безопасности.
В Excel этот параметр отключение макроса VBA без уведомления и только для макроса VBA.
Отключить все макросы с уведомлением. Этот параметр отключает макросы без отключения оповещений системы безопасности, которые будут появляться при необходимости. Так вы можете включать макросы, когда это требуется.
В Excel этот параметр является отключением макроса VBA с уведомлением и применяется только к макросам VBA.
Отключить все макросы кроме макросов с цифровой подписью Макрос отключается, а при этом отображаются оповещения системы безопасности. Однако если макрос подписан надежным издателем, он просто запускается. Если макрос подписан издателем, которому вы еще не доверяете, вы можете включить его и сделать издателя надежным.
В Excel этот параметр отключен, кроме макроса с цифровой подписью, и применяется только к макросам VBA.
Включить все макросы (не рекомендуется, советуем запускать опасное код). Все макрос будет запускаться без подтверждения. Компьютер становится уязвимым для потенциально опасных программ.
В Excel этот параметр относится только к макросам VBA (не рекомендуется, советуем запускать опасной код), и он применяется только к макросам VBA.
Excel также есть контрольныйExcel включить макрос Excel 4.0при включенном макросах VBA. Если этот параметр установить, все параметры макроса VBA будут также применяться к макросам Excel 4.0 (XLM).
Если этот снимок не был выбран, макрос XLM отключется без уведомления.
Доверять доступ к объектной модели проектов VBA Отопустить или разрешить программный доступ к объектной модели Visual Basic для приложений (VBA) из клиента автоматизации. Этот параметр безопасности для кода, написанного для автоматизации программ Office и работы со средой VBA и объектной моделью. Этот параметр настраивается как для каждого пользователя, так и для каждого приложения и по умолчанию не позволяет несанкционированно получать доступ, препятствуя построению потенциально опасных кодов самопроизводения. Чтобы клиенты автоматизации получили доступ к объектной модели VBA, пользователь, работающий с кодом, должен предоставить доступ. Чтобы включить доступ, выберите его.
Примечание: В Microsoft Publisher и Microsoft Access параметр Доверять доступ к объектной модели проектов VBA отсутствует.