Remove module via automation...

E

emailceloftis

Similar to my other post:
Using VS2005, VB.NET,
I want to remove a module from a PPT if it exists. Here's what I've
got:

For Each Vbe As Microsoft.Vbe.Interop.VBProject In
oPres.VBProject.VBE.VBProjects
If Vbe.Name.ToUpper = "Module_Name".ToUpper Then
oPres.VBProject.VBE.VBProjects.Remove(Vbe)
Exit For
End If
Next

Problem is my module name never appears in the list. I also tried
looping through the list of VBComponents but has the same results (my
module was never found).

Can someone spot what I am doing wrong?
 
E

emailceloftis

Similar to my other post:
Using VS2005, VB.NET,
I want to remove a module from a PPT if it exists. Here's what I've
got:

                For Each Vbe As Microsoft.Vbe.Interop.VBProject In
oPres.VBProject.VBE.VBProjects
                    If Vbe.Name.ToUpper = "Module_Name".ToUpper Then
                        oPres.VBProject.VBE.VBProjects.Remove(Vbe)
                        Exit For
                    End If
                Next

Problem is my module name never appears in the list. I also tried
looping through the list of VBComponents but has the same results (my
module was never found).

Can someone spot what I am doing wrong?

Correction I got this to work using VBComponents...
Dim appPPT As New PowerPoint.Application
Dim oPres As PowerPoint.Presentation =
appPPT.Presentations.Open
For Each Vbc As Microsoft.Vbe.Interop.VBComponent In
oPres.VBProject.VBComponents
If Vbc.Name.ToUpper = MODULE_NAME.ToUpper Then
oPres.VBProject.VBComponents.Remove(Vbc)
Exit For
End If
Next
oPres.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject
(oPres)
oPres = Nothing
appPPT.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject
(appPPT)
appPPT = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top