You know, Shyam is a good friend and an excellent coder. I really couldn't see him making some of the mistakes in the code you posted.
In you other code are there PUBLIC or Global variables? Any untrapped error will kill these and cause problems.
See if this improves things or at least gives a start point.
Sub AttachSelection()
Dim oPres As Presentation
Dim oSlide As Slide
Dim sIDs As String
Dim sTempFile As String
Dim sFileName As String
Dim sFilePath As String
Dim iCounter As Integer
Dim ActiveSlideNumber As Long
Dim oOutlookApp As Object
Dim olMailItem As Variant
sFileName = ActivePresentation.Name
If ActivePresentation.Path = "" Then ' not saved
MsgBox "Save me"
Exit Sub
End If
'Create a string containing slide IDs of selection
sIDs = ":"
For Each oSlide In ActiveWindow.Selection.SlideRange
sIDs = sIDs & CStr(oSlide.SlideID) & ":"
Next oSlide
'Create path to store dummy file - NOT the same path as open presentation!
sTempFile = Environ("TEMP") & "\" & sFileName
'Save a copy of the original file
Call ActivePresentation.SaveCopyAs(sTempFile)
'Open the copy
Set oPres = Application.Presentations.Open(FileName:=sTempFile, WithWindow:=False)
'Search for IDs which do not appear in the ID string and delete those slide
With oPres
For iCounter = .Slides.Count To 1 Step -1
If InStr(1, sIDs, ":" & CStr(.Slides(iCounter).SlideID) & ":") = 0 Then
.Slides(iCounter).Delete
End If
Next iCounter
End With
ActiveSlideNumber = oPres.Slides.Count
oPres.Save
oPres.Close ' note close AFTER checking selected slides!
'Attaches temp file to Outlook email
'If Outlook is not open this takes for ever - you want to open a new instance of outlook in this case?
err.Clear
On Error Resume Next
Set oOutlookApp = GetObject(Class:="Outlook.application")
If err <> 0 Then ' outlook is closed
Set oOutlookApp = CreateObject("Outlook.application")
End If
On Error GoTo err
With oOutlookApp.CreateItem(olMailItem)
.Attachments.Add sTempFile
.Subject = sFileName & " (" & ActiveSlideNumber & " Slide(s))"
.Display
End With
'Delete temp file
Kill sTempFile
Exit Sub
err:
MsgBox err.Description
End Sub
Is there a link to Shyam's original code?