BetterDoc is a Microsoft Office Word add-in that leverages AI/LLM technology to intelligently reimagine and improve your document content while preserving formatting, hyperlinks, and document structure.
- Paragraph-by-Paragraph Processing: Navigate through your document paragraph by paragraph with intelligent skipping of short paragraphs, questions, and empty content
- AI Content Enhancement: Use Azure OpenAI or local LLM models to rewrite content with customizable prompts
- Formatting Preservation: Automatically detects and preserves text formatting (bold, italic, underline, font sizes)
- Hyperlink Protection: Detects hyperlinks and ensures they remain intact during content processing
- Leading Format Detection: Preserves special formatting at the beginning of paragraphs
- Selective Processing: Only processes paragraphs with 7+ words, skips questions and empty paragraphs
- Word Count Control: Prevents LLM from increasing word count beyond original content
- Retry Logic: Automatically retries if hyperlink text is lost during processing
- Batch Operations: Select and process multiple paragraphs simultaneously
- Visual Navigation: Up/Down arrow buttons to move through paragraphs
- Real-time Preview: View original and modified text side-by-side
- Document Highlighting: Current paragraph is selected in the document for easy reference
- Progress Tracking: Visual list of selected paragraphs with click-to-jump functionality
The project consists of two main components:
- Frontend: HTML/CSS/JavaScript task pane interface
- Backend Integration: Communicates with Azure OpenAI via proxy service
- Office.js Integration: Uses Microsoft Office JavaScript API for document manipulation
- Azure OpenAI Integration: Secure connection to Azure OpenAI using managed identity
- CORS Handling: Enables cross-origin requests from the Office add-in
- Request Processing: Handles prompt formatting and response parsing
- Microsoft Word (Office 365 or Office 2019+)
- Azure OpenAI service access
- Node.js (18+)
- Azure subscription for hosting the proxy service
- Create an Azure OpenAI resource in your Azure subscription
- Deploy a GPT model (e.g., GPT-4)
- Note your endpoint URL and deployment name
- Configure managed identity for authentication
- Navigate to
ollama-service/directory - Install dependencies:
npm install
- Set environment variables:
AZURE_OPENAI_ENDPOINT=https://your-openai-resource.openai.azure.com/ AZURE_OPENAI_DEPLOYMENT=your-deployment-name
- Deploy to Azure App Service or run locally:
npm start
- Navigate to
betterdoc-office-addin/BetterdocAddin/directory - Install dependencies:
npm install
- Build the add-in:
npm run build
- Sideload the add-in in Word:
- Open Word
- Go to Insert > My Add-ins > Upload My Add-in
- Select the
manifest.xmlfile
-
Open the Add-in: In Word, find "Betterdoc" in your add-ins and open the task pane
-
Navigate Document: Use the ↑/↓ buttons to move through paragraphs
- The tool automatically skips short paragraphs (<7 words), questions, and empty content
- Current paragraph is highlighted in the document
-
Select Content: Check the "Reimagine" checkbox for paragraphs you want to process
- Use "Select All" to mark all valid paragraphs
- Use "Unselect All" to clear selections
-
Configure Settings:
- Prompt Selection: Choose from predefined prompts or create custom ones
- "Make More Professional": Enhances formal tone
- "Reduce Word Count": Makes content more concise
- "Custom Prompt": Write your own instructions
- Model Selection: Choose from available AI models
- Server Address: Configure proxy service endpoint
- Prompt Selection: Choose from predefined prompts or create custom ones
-
Process Content: Click "Reimagine Now" to send selected paragraphs to the AI
- The tool processes each paragraph individually
- Original formatting and hyperlinks are preserved
- Progress is shown in the debug log
-
Review and Apply:
- Review AI-generated content in the "Modified/LLM Text" area
- Edit the content if needed
- Click "Apply" for current paragraph or "Apply All" for batch processing
Create specific instructions for the AI:
Rewrite this content for a technical audience. Use precise terminology and include specific details. Maintain all hyperlinks and formatting.
The tool automatically:
- Detects and preserves bold, italic, underline formatting
- Maintains font sizes and special formatting
- Handles complex formatting patterns within paragraphs
- Automatically detects hyperlinks in paragraphs
- Instructs AI to preserve exact link text
- Retries up to 3 times if link text is modified
- Reverts to original if preservation fails
- Select multiple paragraphs using checkboxes
- Process all selected content with one click
- Apply changes to all processed paragraphs simultaneously
- Ensure the Azure proxy service is running and accessible
- Check CORS configuration if seeing network errors
- Verify Azure OpenAI endpoint and deployment settings
- Use "Refresh Source" button to reload document content
- Check debug log for formatting detection issues
- Ensure document doesn't have complex nested formatting
- Check debug log for detailed error messages
- Verify AI model is available and responding
- Try reducing paragraph length if processing fails
Edit the window.availableModels array in taskpane.html to add/remove AI models:
window.availableModels = [
"gemma3:12b",
"gemma3:27b",
"qwq:latest",
"deepseek-r1:14b",
"deepseek-r1:32b"
];Modify the PROMPTS object in taskpane.js to add predefined prompts:
const PROMPTS = {
professional: "Rewrite this and make it sound more professional...",
concise: "Reduce the word count as much as possible...",
custom: ""
};betterdoc2/
├── betterdoc-office-addin/
│ └── BetterdocAddin/
│ ├── manifest.xml # Office add-in manifest
│ ├── src/
│ │ └── taskpane/
│ │ ├── taskpane.html # Main UI
│ │ ├── taskpane.js # Core logic
│ │ └── styles.css # Styling
│ └── package.json
├── ollama-service/
│ ├── server.js # Azure proxy server
│ └── package.json
└── readme.md
taskpane.js: Main application logic, Office.js integrationserver.js: Azure OpenAI proxy servicemanifest.xml: Office add-in configurationtaskpane.html: User interface definition
The add-in uses Office.js APIs for:
- Document paragraph access and manipulation
- Text formatting detection and application
- Hyperlink detection and preservation
- Document selection and highlighting
- Uses Azure managed identity for secure API authentication
- No user credentials stored locally
- Document content processed through secure Azure endpoints
- All communication encrypted via HTTPS
This project is licensed under the MIT License.
For issues and feature requests, please check the debug log in the add-in for detailed error messages and consult the troubleshooting section above.