When I try to save an Excel file that contains a macro I get the error “Excel cannot open the file because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.” I can’t seem to figure out the cause or how to resolve this. Any ideas? A sample is attached.
Hi,
In your attached archive, I can see only your template Excel file “MacroTest.xlsm” in the “Reports” folder. Do you just open and re-save the file using Aspose.Cells API? I could not find source code file (C#/VB).
Also could you try our latest version/fix: Aspose.Cells for .NET v7.0.2.2 if it works fine.
Thank you.
I just tried the latest version, same problem. Attached are the uncompiled project files.
Hi,
Thanks for the sample project.
I think you should change your code a bit. Below is the changed code, changed part is highlighted as red color:
xlsWorkbook.Save(Me.Response, "MacroTest.xlsm",
ContentDisposition.Attachment, New OoxmlSaveOptions(SaveFormat.Xlsm))
I figured it had something to do with save options. Thanks.