Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The Object that would not close!

Status
Not open for further replies.

pervinpj

Programmer
Jul 10, 2003
11
0
0
US
I Am creating a massive procedure which creates a powerpoint based on information which is E-mailed to my database's E-mail address (yes, it has it's own E-mail address). It gather's information from an XLS attachment in the E-mail. All of that works just fine. The problem I'm having seems really simple:
within the VB application

Set ActivePresentation = GetObject("c:\manning data\enlisted manning shell.ppt") 'Named to avoid confusion
Set PowerPoint = ActivePresentation.Application

blah, blah blah... (code to alter the powerpoint this all works just fine)

ActivePresentation.SaveAs ("c:\Manning Data\Manning" & Format$(Now(), "ddmmyy") & ".ppt")
ActivePresentation.Close
PowerPoint.Quit
Set PowerPoint = Nothing
Set ActivePresentation = Nothing

The problem lies in the fact that in the task manager, powerpnt.exe remains, and I can only open the file it was saved as (SaveAs line) in Read-Only. And the only way I have to open it in non-read only is to end task on powerpnt.exe ... not cool, I need it automated. The person who will be clicking the button linked to this procedure doesn't even know what the task manager is! Please help. My computer doesn't love me anymore![sadeyes]

[bigears] PervinPJ [pipe]
 
Hi PervinPJ

In my opinion the code to release the objects is in the wrong order. In your code PowerPoint quits (PowerPoint.Quit) while there is still a object reference to the Presentation. The reference is cleared to late (Set ActivePresentation = Nothing). Because of this, PPT does not really quit and the file is still open (-> next opening only possible with read-only).

Instad of
ActivePresentation.Close
PowerPoint.Quit
Set PowerPoint = Nothing
Set ActivePresentation = Nothing
try this order:
ActivePresentation.Close
Set ActivePresentation = Nothing
PowerPoint.Quit
Set PowerPoint = Nothing

HTH
Philipp


 
Unfortunately, my computer still has no love for me. Thank you for that though. I tried it, it works faster for some reason now, but still doesn't work. There it is... powerpnt.exe staring at me on the list of processes.
 
Hi pervinpj,

pvw's suggestion was good and I can believe it runs faster, but if you still have a task it implies you still have a pointer somewhere.

I can run the code as posted without leaving a trail of tasks behind me so is there a chance you have set a pointer somewhere in the code you haven't posted (the blah, blah bit)?

Enjoy,
Tony
 
Well, I should have asked this to begin with, but now I've found the solution. I only wanted to close it so that I could open it visibly with the ability to edit it. The servers for objects will always remain running as long as the code is running. Rather than closing it, I just made it visible:

For x = 1 To PowerPoint.Presentations.Count
If PowerPoint.Presentations(x).Name = "Manning" & Format$(Now(), "ddmmyy") Then
PowerPoint.Presentations(x).NewWindow
End If
Next x

End Sub ' After 8 hours of running it in debug, I finally got to run this line!

[Thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top