Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / November 2006

Tip: Looking for answers? Try searching our database.

Control Toolbox text box and vba - a bug?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Geoff Cox - 16 Nov 2006 17:46 GMT
Hello,

I wonder if anyone can sort this one?!

I create a presentation with one slide which has a text box inserted
using the Control Toolbox.

The first block of code below is run in order to find the number of
slides in a presentation. It works fine when no text box but with the
text box it does not run and all I can see is that I get an entry in
the Project Explorer

VBA Project(test.ppt)
Microsoft PowerPoint Object
Slide1

(test.ppt is the 1 slide presentation with the text box on it)

Shyam has suggested that this was a bug and said I should try the
second block of code below - but this has the same effect as above.

Any ideas?!

Cheers

Geoff

--------------------------my first code-----------------------------
Sub MyMacro(strMyFile As String)

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

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

End With

oPresentation.Close

End Sub
------------------------------------------------------------

---------------------2nd code--------------------------

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
Geoff Cox - 17 Nov 2006 00:11 GMT
>Hello,
>
[quoted text clipped - 7 lines]
>text box it does not run and all I can see is that I get an entry in
>the Project Explorer

A little daylight was brought about by a comment seen in another
context - the macro security settings of PowerPoint apply to the
computer not to a particular presentation.

So, when I open PPT and change the security setting to the low state -
then the vba code works!

However, I would like to know why the following does not work when the
PPT setting is medium - any ideas?

Geoff

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 = msoAutomationSecurityLow
Application.AutomationSecurity

Set oPPT = Presentations.Open(FileName:=strMyFile, WithWindow:=False)
CountSlides = oPPT.Slides.Count

oPPT.Close 'Close w/o saving.
Set oPPT = Nothing

End Sub

>VBA Project(test.ppt)
>Microsoft PowerPoint Object
[quoted text clipped - 50 lines]
>
>End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.