John,
Thanks for this. I appreciate you taking the time to clean the code. It's true that Shyam's code was almost definitely much better than what I posted (I make no claims about my abilities) and I should have removed or at least modified his copyright notice at the top. I don't have the original link to his code since I received the code snippets from someone else who probably also made some minor modifications as well.
Unfortunately after swapping in your code and then removing all the global variables, the same issue is still occurring.
On another note, when I run the below sub (another sub from the same module), everything continues to run fine.
Thanks for your continued help.
******************************************** Sub AttachFullDoc(Optional control As IRibbonControl) Dim oPres As Presentation Dim oSlide As Slide Dim sIDs As String Dim sTempFile As String Dim sFileName As String Dim iCounter As Integer Dim sBadChars As String Dim wshShell 'Forms temp file name sFileName = ActivePresentation.Name If sFileName = "" Then Exit Sub sFileName = CleanFileNameFullDoc(sFileName) 'Determines directory for temp file Set wshShell = CreateObject("WScript.Shell") sFilePath = wshShell.SpecialFolders("MyDocuments") 'Create path to store dummy file sTempFile = sFilePath & "\" & sFileName 'Save a copy of the original file Call ActivePresentation.SaveCopyAs(sTempFile) 'Open the copy Set oPres = Application.Presentations.Open(sTempFile, False, False, False) 'Attaches temp file to Outlook email 'If Outlook is not open this takes a while - may want to consider opening a new instance of outlook for this? Set oOutlookApp = GetObject("", "Outlook.application") Set oMessage = oOutlookApp.CreateItem(olMailItem) With oMessage .Attachments.Add sTempFile .Subject = sFileName .Display End With 'Delete temp file Kill sTempFile End Sub





Reply With Quote
