Control Toolbox/Text box problem?

G

Geoff Cox

Hello,

The following code normally works - and gives me the number of slides
in a presentation.

But! If I use it on a ppt file which has a text box added - using the
Control Toolbox, with the ability to enter some text - then it bombs
out!

Any ideas please?

Cheers

Geoff


Sub check_number_of_slides(strMyFile As String)

Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)
Dim CountSlides As Integer

With oPresentation
CountSlides = oPresentation.Slides.Count
MsgBox "number of slides in " & strMyFile & " is " & CountSlides

oPresentation.Save
oPresentation.Close

End With

Set oPresentation = Nothing

End Sub
 
S

Shyam Pillai

This was a bug that I discovered by accident some months ago. Try the
following istead.

Sub check_number_of_slides(strMyFile As String)

Dim secAutomation As MsoAutomationSecurity
Dim oPPT As Presentation
Dim CountSlides As Integer

secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityForceDisable
Set oPPT = Presentations.Open(FileName:=strMyFile,WithWindow:=False)
Application.AutomationSecurity = secAutomation

CountSlides = oPPT.Slides.Count
MsgBox "number of slides in " & strMyFile & " is " & CountSlides

' oPPT.NewWindow 'Optional if you want to see the document window
oPPT.Close 'Close w/o saving.
Set oPPT = Nothing

End Sub


--
Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm
 
G

Geoff Cox

This was a bug that I discovered by accident some months ago. Try the
following istead.

Shyam,

I have tried but your code does not work with the ppt files with a
text box - is the following relevant?

When the macro stops and I look in the Project Explorer I see

VBA Project (name_of_file_with_text_box_on_second_slide.ppt)
- Microsoft PowerPoint Objects
Slide 2

The text boxes are mostly on slide 2.

Geoff
 
G

Geoff Cox

On Mon, 13 Nov 2006 10:56:49 -0500, "Shyam Pillai"

Shyam,

I also notice that the value of

Application.AutomationSecurity

is already 3.

Does this mean that this is not the problem?

Cheers

Geoff
 

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