# Microsoft.Office.Interop.Word

**Kind:** Service

**Source:** `Pams/Core/Pams.Core/Pams.Core.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.Office.Interop.Word` is a NuGet package dependency declared in `Pams.Core.csproj` for working with Microsoft Word documents through the Office COM interop API. It supports legacy-format document processing where the core service runs on a Windows host with Microsoft Word installed.

## Diagram

```mermaid
sequenceDiagram
    participant Caller
    participant PamsCore as Pams.Core
    participant Interop as Microsoft.Office.Interop.Word
    participant Word as Microsoft Word

    Caller->>PamsCore: Request document operation
    PamsCore->>Interop: Create Word application and document
    Interop->>Word: Open, read, or save document
    Word-->>Interop: Document result
    Interop-->>PamsCore: Interop document data
    PamsCore-->>Caller: Return operation result
```

## Usage

```ts
type DocumentConversionRequest = {
  sourcePath: string;
  outputPath: string;
};

async function convertLegacyWordDocument(
  request: DocumentConversionRequest,
): Promise<void> {
  const response = await fetch("/api/documents/convert-word", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(request),
  });

  if (!response.ok) {
    throw new Error("Word document conversion failed.");
  }
}

await convertLegacyWordDocument({
  sourcePath: "C:\\documents\\input.doc",
  outputPath: "C:\\documents\\output.docx",
});
```

## AI Coding Instructions

- Keep `Microsoft.Office.Interop.Word` references in the .NET project that owns Word automation; TypeScript clients should call an API rather than automate Word directly.
- Release COM objects and close documents and application instances when document work completes.
- Run Word interop only on Windows hosts where Microsoft Word is installed and available to the service account.
- Treat source document paths and output paths as untrusted input; validate allowed locations before passing them to the Word automation layer.

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (1)

- `Pams.Core` — `Pams/Core/Pams.Core/Pams.Core.csproj`:1
