claude-code - 💡(How to fix) Fix [BUG] When saving xlsm files using VBA, openpyxl destroys all cell formulas (replacing them with cached values). [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48547Fetched 2026-04-16 06:57:07
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×5commented ×1

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code did today:
▎ When saving xlsm files using VBA, openpyxl destroys all cell formulas (replacing them with cached values). ▎ What happened in this session: all formulas in PoetrySlamAuswertungen.xlsm were corrupted.

What Should Happen?

So that was my mistake – I used openpyxl even though it isn’t suitable for xlsm files with VBA. Restoring the formulas then took you about 5 hours. I’m sorry about that.

Error Messages/Logs

Steps to Reproduce

  • Analysis sheet restored from backup (Copy-0414-14:11.xlsm) (rows 1–115)
    • External file references cleaned up using Copy() via PowerShell

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

Claude Code 2.1.109

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

No response

extent analysis

TL;DR

Avoid using openpyxl for xlsm files with VBA to prevent formula corruption.

Guidance

  • Consider using a library that supports VBA macros, such as xlwings or win32com, to handle xlsm files.
  • Verify that the chosen library preserves cell formulas when saving files.
  • Test the new library with a sample xlsm file containing VBA macros to ensure compatibility.
  • If openpyxl is still required, explore alternative methods for preserving formulas, such as storing them separately or using a different file format.

Example

No code example is provided due to the lack of specific implementation details.

Notes

The issue is specific to xlsm files with VBA macros, and the solution may vary depending on the chosen library or approach.

Recommendation

Apply workaround: Use a library that supports VBA macros, such as xlwings or win32com, to handle xlsm files. This is because openpyxl is not suitable for preserving formulas in xlsm files with VBA macros.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING