I am experiencing an odd behavior of my PowerPoint Ribbon.
I created a pptm file with a Ribbon for a quick-link to 2 vba codes. One is copying data from an xls-file to a chart. The other one is saving a copy of the presentation as a pptx file and a pdf file (savecopyas) and sends an email with outlook.
Everything works smooth as long as I only save the pdf file. If I also create the pptx file (or a different named pptm file) the vba script only runs the first time - afterwards the ribbon for both actions ist not working anymore. It is prompting an error saying the vba code was not found.
What did I experience?
1) The xls-code runs as often as you like as long as the email code is not started.
2) There is no warning that the pptx file will not contain any vba code anymore (that's what Excel would tell you)
3) If I add a last line that is saving the pptm as pptx, the modules keep in the pptx until it is closed. The ribbon commands are working correctly in this case of a pptx file - as often as you like.
4) Starting the email vba code in the pptm from a button manually works smooth all the time, no matter how often it is started.
I only found 2-3 similar questions / errors on the web with no explanation or only workarounds.
Is there anybody who can explain and help me on this odd behavior?
Kind regards,
Mario
Here is the code:
Sub Email(ByVal control As IRibbonControl)
Dim Send_Email, olApp As Object
Dim Send_1, Send_2 As String
With ActivePresentation
.SaveCopyAs _
FileName:=ActivePresentation.Path & "\" & "Test" & ".pptx", _
FileFormat:=ppSaveAsOpenXMLPresentation
End With
With ActivePresentation
.SaveCopyAs _
FileName:=ActivePresentation.Path & "\" & "Test" & ".pdf", _
FileFormat:=ppSaveAsPDF
End With
Send_1 = ActivePresentation.Path & "\" & "Test" & ".pptx"
Send_2 = ActivePresentation.Path & "\" & "Test" & ".pdf"
Set olApp = CreateObject("Outlook.Application")
Set Send_Email = olApp.CreateItem(0)
With Send_Email
.To = "test@gmail.com"
.Subject = "Test"
.Body = "Hallo "
.Attachments.Add Send_2
.Attachments.Add Send_1
.Send
End With
Set olApp = Nothing
End Sub