Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-20-2011, 08:25 AM
ghumdinger ghumdinger is offline oshp.TextFrame.TextRange.Font <The specified error is out of range> Windows 7 oshp.TextFrame.TextRange.Font <The specified error is out of range> Office 2010 (Version 14.0)
Advanced Beginner
oshp.TextFrame.TextRange.Font <The specified error is out of range>
 
Join Date: Jul 2010
Posts: 64
ghumdinger is on a distinguished road
Default oshp.TextFrame.TextRange.Font <The specified error is out of range>

Hi all,

I'm trying to change all the text in a pptx (using Office 2010) to Times New Roman 24 pt. I'm not good with code. I found this on http://www.pptalchemy.co.uk/vbasamples.html :

But I got an out of range error: oshp.TextFrame.TextRange.Font <The specified error is out of range>.

Can someone help me? Thanks!

Regards,
Jay

Code:
Sub allchange()
Dim osld As Slide, oshp As Shape
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoPlaceholder Then
'Title text change values as required
If oshp.PlaceholderFormat.Type = 1 Or oshp.PlaceholderFormat.Type = 3 Then
With oshp.TextFrame.TextRange.Font
.Name = "Times New Roman"
.Size = 24
.Color.RGB = RGB(0, 0, 255)
.Bold = msoFalse
.Italic = msoFalse
.Shadow = False
End With
End If
If oshp.PlaceholderFormat.Type = 2 Or oshp.PlaceholderFormat.Type = 7 Then
'Body text change values as required
With oshp.TextFrame.TextRange.Font
.Name = "Times New Roman (Body)"
.Size = 24
.Color.RGB = RGB(0, 0, 255)
.Bold = msoFalse
.Italic = msoFalse
.Shadow = False
End With
End If
End If
Next oshp
Next osld
End Sub

Reply With Quote
  #2  
Old 10-21-2011, 03:45 AM
PetLahev PetLahev is offline oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Windows XP oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Office 2007
Novice
 
Join Date: Oct 2011
Posts: 7
PetLahev is on a distinguished road
Default

Try this one

ONLY SAMPLE
Code:
If shp.HasTextFrame Then
   If shp.TextFrame.HasText Then
       With shp.TextFrame.TextRange.Font
              .Size = 24
              .Name = "Times New Roman"
       End With
   End If
End If
Reply With Quote
  #3  
Old 10-22-2011, 12:46 AM
ghumdinger ghumdinger is offline oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Windows 7 oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Office 2010 (Version 14.0)
Advanced Beginner
oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt;
 
Join Date: Jul 2010
Posts: 64
ghumdinger is on a distinguished road
Default

Hi, thanks.

I got an "object expected", error 424 error for this line:

If shp.HasTextFrame Then

Best wishes,
Jay
Reply With Quote
  #4  
Old 10-22-2011, 02:02 AM
PetLahev PetLahev is offline oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Windows XP oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Office 2007
Novice
 
Join Date: Oct 2011
Posts: 7
PetLahev is on a distinguished road
Default

here you are the whole code
Code:
Sub allchange()
    
    Dim osld As Slide, oshp As Shape
    
    
    For Each osld In ActivePresentation.Slides
        For Each oshp In osld.Shapes
            If oshp.Type = msoPlaceholder Then
            
                'Title text change values as required
                If oshp.PlaceholderFormat.Type = 1 Or oshp.PlaceholderFormat.Type = 3 Then
                    If oshp.HasTextFrame Then
                        If oshp.TextFrame.HasText Then
                            With oshp.TextFrame.TextRange.Font
                                .Name = "Times New Roman"
                                .Size = 24
                                .Color.RGB = RGB(0, 0, 255)
                                .Bold = msoFalse
                                .Italic = msoFalse
                                .Shadow = False
                            End With
                        End If
                    End If
                End If
            
                If oshp.PlaceholderFormat.Type = 2 Or oshp.PlaceholderFormat.Type = 7 Then
                    'Body text change values as required
                    
                    If oshp.HasTextFrame Then
                        If oshp.TextFrame.HasText Then
                            With oshp.TextFrame.TextRange.Font
                                .Name = "Times New Roman (Body)"
                                .Size = 24
                                .Color.RGB = RGB(0, 0, 255)
                                .Bold = msoFalse
                                .Italic = msoFalse
                                .Shadow = False
                            End With
                        End If
                    End If
                    
                End If
            End If
        Next oshp
    Next osld
    
End Sub
Reply With Quote
  #5  
Old 10-22-2011, 02:28 AM
ghumdinger ghumdinger is offline oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Windows 7 oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Office 2010 (Version 14.0)
Advanced Beginner
oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt;
 
Join Date: Jul 2010
Posts: 64
ghumdinger is on a distinguished road
Default

Awesome. Worked like a charm.

Thanks & have a great weekend!
Reply With Quote
  #6  
Old 12-09-2011, 10:36 PM
JohnWilson JohnWilson is offline oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Windows 10 oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Office 2019
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Pet

Thanks for pointing out the need to check for TextFrame & Text, I've modifed the original code with a credit!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't delete range - error 5904 expatriate Word VBA 1 06-03-2011 12:12 AM
Runtime error 5487 - Word cannot complete the save to to file permission error franferns Word 0 11-25-2009 05:35 AM
Receive error cannot open this form because an error occurred in BCM 2007 bornhusker Outlook 0 06-01-2009 10:28 AM
oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Subscript out of range error KHTAY Excel 6 03-28-2009 11:18 PM
oshp.TextFrame.TextRange.Font &lt;The specified error is out of range&gt; Mysterious "Subscript out of range" error rnstewart Excel 4 12-29-2005 01:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:02 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft