Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Fri Feb 12, 2021 9:14 am

Hi,

I'd like to be able to alter a Powerpoint file that has macros. I'd like to be able to save it to a new file that maintains those macros.
However, the macros seem to be stripped off in the saving process.

Code: Select all
            var pptPresentation = new Presentation(presentationTemplate, FileFormat.Auto);
         
...
Code to alter presentation
...       

            var hasMacros = pptPresentation.HasMacros;
            using (var presentation = new MemoryStream())
            {
                pptPresentation.SaveToFile(presentation, FileFormat.Auto);
            }


hasMacros is true, suggesting that altering it hasn't stripped the macros, but the saved file has none.
I've tried some of the different file formats with no luck. There isn't a specific pptm format.

Thanks,
James

JamesNicolson
 
Posts: 3
Joined: Fri Feb 12, 2021 8:59 am

Fri Feb 12, 2021 10:15 am

Hi James,

Thanks for your inquiry.
After an initial test with Spire.Presentation Pack Hotfix Version:6.2.2, I didn't reproduce your issue.
To help us reproduce and investigate the issue, please provide us with your Powerpoint file. Thank you for your assistance in advance.

Sincerely
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Sat Feb 13, 2021 3:05 pm

Hi Amy,

Thanks for the quick reply.
I've attached an example spreadsheet that has one simple macro, 'FitMessages'.
This macro is missing when it's loaded and saved as in the code above.

In fact, if I try to save it with a 'pptm' extension, Powerpoint won't open it. It says the extension does not match the format of the file.

Thanks in advance,
James

JamesNicolson
 
Posts: 3
Joined: Fri Feb 12, 2021 8:59 am

Mon Feb 15, 2021 10:31 am

Hello,

Thanks for sharing more information and sorry for the late reply as weekend.

I test your presentation file with the latest Spire.Presentation Pack Hotfix Version:6.2.2, but still did not reproduce your issue. Please make sure that you are using the latest Spire.Presentation. If the issue still exists, please provide us with your OS information (E.g. Win7, 64 bit) and region setting (E.g. China, Chinese) for reference.

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Feb 18, 2021 9:53 am

Hi Marcia,

I'm using version 6.2.2 on Windows 10 64 bit and the region setting is English (United Kingdom).

I load it from one file and save to another (which I have to save with a .ppt extension in order to be able to open it).
In fact, I can't find any mention of supporting the .pptm format in your documentation.

Are you saving the new file directly over the old file, or to a new file? And are you absolutely sure the macro is still there?

Thanks in advance,
James

JamesNicolson
 
Posts: 3
Joined: Fri Feb 12, 2021 8:59 am

Fri Feb 19, 2021 4:00 am

Hello,

Thanks for sharing more information!

I am sorry that due to the complexity of the technology, our Spire.Presentation has not supported creating the file with macros yet. So the result file cannot be opened when you save the file to a new .pptm via stream. We are considering adding the feature to our future upgrade list. If it is achieved in the future, we will let you know.

Now I recommend that you can save the file to a new .pptm file directly through pptPresentation.SaveToFile(“directToFile.pptm”, FileFormat.Auto); temporarily. The macro will still exist and the result file can be opened by this way. I also attached my result file.

Anyway, we will let you know if there is any good news. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Presentation