MWE > said:
Your suggestion solved my problem. It seems so obvious ... However, it
also seems reasonable to me that the default for the visibility
property should be "true"
My code now does most of what I want. I am still running into a
strange problem when I try to process more than 49 ppt files in a row.
I create the ppt object, then sequence through a series of ppt files
(open, operate, save, close) and then quit the ppt object. If the
number of ppt files in the sequence is > 49, I get an error. Initially
the error was "too many open windows". I fixed that by adding code to
close the active window right after closing the ppt file (which also
keeps the task bar from filling up with ppt icons). Now I get an error
indicating that the 50th file can not be opened even though all 49
previous ones have been closed.
Any thoughts?
Though I solved your problem, I am not a skilled programmer. But I had huge
problems with memory leaks and my program kept crashing until I put code in
to release memory at the end of each loop, just before the process repeated
itself. So I will post what I did and maybe you will find it of value.
In my case, I had an array with company info in it, was opening a PPT File
called "Template.ppt", then copying slides from other PPT files and pasting
them into it, then saving the presentation with the company name and going
on to the next company. I tell you all that so the following code at the
end of my procedure to clean up and release memory makes sense. It works,
but good programmers may find fault with it. Still my program was crashing
and no longer is
............................................................................
lots of code and then this to end the sub...
.............................................................................
' This code sets the Title of the ppt file to the name of the Plan
Set oSlide = oPresTemplate.Slides(1)
Set oShape = oSlide.Shapes.Title
oShape.TextFrame.TextRange.Text = strPlanName
Set oShape = Nothing 'Added Aug 4 to release memory
' The following code gets rid of the forward slash that makes VBA think
I'm trying to create
' a new directory - this occurs in the abbreviation P/S for Profit
Sharing. I need to do
' this prior to trying to save the file since the file name is the plan
name with .PPT appended
While InStr(strPlanName, "/") > 0
strPlanNameLeft = Mid$(strPlanName, 1, InStr(strPlanName, "/") - 1)
strPlanNameRight = Mid$(strPlanName, InStr(strPlanName, "/") + 1)
strPlanName = strPlanNameLeft & "_" & strPlanNameRight
Wend
'Save plan with name of company
oPresTemplate.SaveAs DestinationPath + strPlanName & ".PPT" 'Saves
File with Co Name
' Close saved plan and close the object for it
oPPT.Presentations(strPlanName & ".ppt").Close
Set oPresTemplate = Nothing ' added this to try and eliminate memory
leak
'Next line is code to reopen the template file since it was renamed in
the SaveAs procedure
Set oPresTemplate = oPPT.Presentations.Open(Path + filename9, msoFalse,
withwindow:=False)
End Sub