A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Powerpoint
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

TextFrame and VBA



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2005, 09:21 PM
Jeff Jones
external usenet poster
 
Posts: n/a
Default TextFrame and VBA

I have 150+ presentations, each with three hypertext links in a
TextFrame object. I need to modify each of these links. I have a
couple of VBA wonderings.

First, with MS Word I have the normal.dot file and with MS Excel I
have the personal.xls file. Both hold macros or VBA code that can be
executed against any document or spreadsheet. Thus far and as near as
I can tell, PowerPoint doesn't have a counterpart generic template
that will retain macros that may be executed against any presentation.
Is this true?

Second, I've had no problem in the past writing macros that open every
document or spreadsheet, in turn, in a folder. Once open, I can make
changes, save the changes and close and open the next asset.
PowerPoint seems to be so freeform that even if I had a generic
template, there doesn't seem to be any way that I can select a single
TextFrame on the last slide, change the three links and then save and
close the presentation before doing the next in the folder. Have any
of you done anything like this? My testing shows that each TextFrame
has a different object number. Is this true? Have any of you
selected each TextFrame object in a presentation and tested it's
contents for a particular value?

Thank you for your time.

Best Regards,
Jeff Jones


  #2  
Old January 14th, 2005, 10:23 PM
PPTMagician
external usenet poster
 
Posts: n/a
Default

Hi,

First part:
http://www.rdpslides.com/pptfaq/FAQ00245.htm

Second part:
Some VBA info and code snippets that might help:
http://officeone.mvps.org/vba.html
http://www.mvps.org/skp/vba.htm

Glenna


"Jeff Jones" wrote:

I have 150+ presentations, each with three hypertext links in a
TextFrame object. I need to modify each of these links. I have a
couple of VBA wonderings.

First, with MS Word I have the normal.dot file and with MS Excel I
have the personal.xls file. Both hold macros or VBA code that can be
executed against any document or spreadsheet. Thus far and as near as
I can tell, PowerPoint doesn't have a counterpart generic template
that will retain macros that may be executed against any presentation.
Is this true?

Second, I've had no problem in the past writing macros that open every
document or spreadsheet, in turn, in a folder. Once open, I can make
changes, save the changes and close and open the next asset.
PowerPoint seems to be so freeform that even if I had a generic
template, there doesn't seem to be any way that I can select a single
TextFrame on the last slide, change the three links and then save and
close the presentation before doing the next in the folder. Have any
of you done anything like this? My testing shows that each TextFrame
has a different object number. Is this true? Have any of you
selected each TextFrame object in a presentation and tested it's
contents for a particular value?

Thank you for your time.

Best Regards,
Jeff Jones



  #3  
Old January 15th, 2005, 02:19 AM
Jeff Jones
external usenet poster
 
Posts: n/a
Default

Cool. Thank you Glenna.

I'll have fun wandering through the code along with building a
blank.pot file.

Good job.

Take care,
Jeff

On Fri, 14 Jan 2005 13:23:04 -0800, "PPTMagician"
wrote:

Hi,

First part:
http://www.rdpslides.com/pptfaq/FAQ00245.htm

Second part:
Some VBA info and code snippets that might help:
http://officeone.mvps.org/vba.html
http://www.mvps.org/skp/vba.htm

Glenna


"Jeff Jones" wrote:

I have 150+ presentations, each with three hypertext links in a
TextFrame object. I need to modify each of these links. I have a
couple of VBA wonderings.

First, with MS Word I have the normal.dot file and with MS Excel I
have the personal.xls file. Both hold macros or VBA code that can be
executed against any document or spreadsheet. Thus far and as near as
I can tell, PowerPoint doesn't have a counterpart generic template
that will retain macros that may be executed against any presentation.
Is this true?

Second, I've had no problem in the past writing macros that open every
document or spreadsheet, in turn, in a folder. Once open, I can make
changes, save the changes and close and open the next asset.
PowerPoint seems to be so freeform that even if I had a generic
template, there doesn't seem to be any way that I can select a single
TextFrame on the last slide, change the three links and then save and
close the presentation before doing the next in the folder. Have any
of you done anything like this? My testing shows that each TextFrame
has a different object number. Is this true? Have any of you
selected each TextFrame object in a presentation and tested it's
contents for a particular value?

Thank you for your time.

Best Regards,
Jeff Jones




  #4  
Old January 15th, 2005, 04:34 AM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

First, with MS Word I have the normal.dot file and with MS Excel I
have the personal.xls file. Both hold macros or VBA code that can be
executed against any document or spreadsheet. Thus far and as near as
I can tell, PowerPoint doesn't have a counterpart generic template
that will retain macros that may be executed against any presentation.
Is this true?


Yes and no. You can't do something like this with a presentation but if you
write the code and turn it into an addin, once the addin's loaded it becomes,
for all practical purposes, part of PPT and stays that way until you unload it.

Create an ADD-IN with TOOLBARS that run macros
http://www.rdpslides.com/pptfaq/FAQ00031.htm

PowerPoint seems to be so freeform that even if I had a generic
template, there doesn't seem to be any way that I can select a single
TextFrame on the last slide, change the three links and then save and
close the presentation before doing the next in the folder. Have any
of you done anything like this?


Qualified yes. If the text frame in question is the normal body text
placeholder, it's possible to work with it. If it's any ol' text box, then the
problem becomes trickier.

On the other hand, you may not need to worry about the shapes at all.

Each slide has a hyperlinks collection; you can get at the address/subaddress
of each hyperlink w/o having to look for the shapes that contain them.

My testing shows that each TextFrame
has a different object number. Is this true?


Per slide, yes.

Have any of you
selected each TextFrame object in a presentation and tested it's
contents for a particular value?


Yes. Here's some sample code to get you started. Also have a look at the VBA
Programming section at http://www.pptfaq.com and the other pages it links to.

Sub Lime()

Dim oSl as Slide
Dim oSh as Shape
Dim oHl as Hyperlink

For each oSl in ActivePresentation.Slides
' display all of the text
For Each oSh in oSl.Shapes
If oSh.HasTextFrame Then
I oSh.TextFrame.HasText Then
Debug.Print oSh.TextFrame.TextRange.Text
End if
End if
Next ' Shape
' list the hyperlinks
For Each oHl in oSl.Hyperlinks
Debug.Print oHl.Address
Debug.Print oHl.SubAddress
Next ' Hyperlink
Next ' Slide

End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #5  
Old January 15th, 2005, 05:06 AM
Jeff Jones
external usenet poster
 
Posts: n/a
Default

Thank you Steve. I believe that, with your help, and that of others,
I'm sneaking up on a solution to this latest opportunity.

Take care,
Jeff

On Fri, 14 Jan 2005 22:34:10 EST, Steve Rindsberg
wrote:

First, with MS Word I have the normal.dot file and with MS Excel I
have the personal.xls file. Both hold macros or VBA code that can be
executed against any document or spreadsheet. Thus far and as near as
I can tell, PowerPoint doesn't have a counterpart generic template
that will retain macros that may be executed against any presentation.
Is this true?


Yes and no. You can't do something like this with a presentation but if you
write the code and turn it into an addin, once the addin's loaded it becomes,
for all practical purposes, part of PPT and stays that way until you unload it.

Create an ADD-IN with TOOLBARS that run macros
http://www.rdpslides.com/pptfaq/FAQ00031.htm

PowerPoint seems to be so freeform that even if I had a generic
template, there doesn't seem to be any way that I can select a single
TextFrame on the last slide, change the three links and then save and
close the presentation before doing the next in the folder. Have any
of you done anything like this?


Qualified yes. If the text frame in question is the normal body text
placeholder, it's possible to work with it. If it's any ol' text box, then the
problem becomes trickier.

On the other hand, you may not need to worry about the shapes at all.

Each slide has a hyperlinks collection; you can get at the address/subaddress
of each hyperlink w/o having to look for the shapes that contain them.

My testing shows that each TextFrame
has a different object number. Is this true?


Per slide, yes.

Have any of you
selected each TextFrame object in a presentation and tested it's
contents for a particular value?


Yes. Here's some sample code to get you started. Also have a look at the VBA
Programming section at http://www.pptfaq.com and the other pages it links to.

Sub Lime()

Dim oSl as Slide
Dim oSh as Shape
Dim oHl as Hyperlink

For each oSl in ActivePresentation.Slides
' display all of the text
For Each oSh in oSl.Shapes
If oSh.HasTextFrame Then
I oSh.TextFrame.HasText Then
Debug.Print oSh.TextFrame.TextRange.Text
End if
End if
Next ' Shape
' list the hyperlinks
For Each oHl in oSl.Hyperlinks
Debug.Print oHl.Address
Debug.Print oHl.SubAddress
Next ' Hyperlink
Next ' Slide

End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
=============================================== =


  #6  
Old January 15th, 2005, 04:26 PM
Brian Reilly, MS MVP
external usenet poster
 
Posts: n/a
Default

Jeff,
Here's another piece of code in addition to Steve's that I use all the
time as a wrapper to iterate through all shapes on all slides. Note,
I've commented out the section that you can change exactly what you
do, but the top and bottom parts are the iteration code.

Shouldn't be hard to do what you want especially if you had the list
of hyperlinks in an Excel worksheet which you could read as variable
values.

Brian Reilly, PowerPoint MVP
  #7  
Old January 15th, 2005, 05:49 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article , MS MVP Brian Reilly
wrote:
Jeff,
Here's another piece of code in addition to Steve's that I use all the
time as a wrapper to iterate through all shapes on all slides. Note,
I've commented out the section that you can change exactly what you
do, but the top and bottom parts are the iteration code.


Brian reformats his hard drive quite often. Chances are he lost his mind the
last time he did it. It's one of those pesky hidden files, ya know?

Sub DiddleAllTheShapes()

Dim oSh as Shape
Dim oSl as Slide

' Look at each slide
For Each oSl in ActivePresentation.Slides
' Look at each shape on the slide
For each oSh in oSl.Shapes
' Do whatever you need to with the shape
With oSh
Debug.Print .Name
.Left = .Left + 10
' .Whatever
End With ' The shape
Next ' Shape
Next ' Slide

End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


  #8  
Old January 16th, 2005, 03:34 PM
Brian Reilly, MS MVP
external usenet poster
 
Posts: n/a
Default

Thanks Steve for pointing out that I forgot to paste in my version


Sub Iterate_Through_All_Shapes_And_Read_Tags()

'PURPOSE: Refers to EACH object on EACH page and checks for a tags
..name
'Then if it is a StickyStyle Name
'Developer: Brian Reilly January 2001
Dim iShape As Integer
Dim iSlide As Integer
Dim iTags As Integer


For iSlide = 1 To ActivePresentation.Slides.Count
With ActivePresentation.Slides(iSlide)
For iShape = 1 To
ActiveWindow.Presentation.Slides(iSlide).Shapes.Co unt
'No need to select the object in order to use strShape

With
ActiveWindow.Presentation.Slides(iSlide).Shapes(iS hape)
'''''''''''Substitute whatever code to the End of Substitute
For iTags = 1 To .Tags.Count

If .Tags.Name(iTags) = "STICKYSTYLE" Then
MsgBox "The shape " &
ActiveWindow.Presentation.Slides(iSlide) _
.Shapes(iShape).Name & " has a
Tags.Name of " & Chr(13) _
& .Tags.Name(iTags) & Chr(13) _
& "and has a Tags.Value of " &
Chr(13) & .Tags.Value(iTags)
''PROCEED WITH NEXT TAG AND NEXT OBJECT
End If

Next iTags
End With

''''''''''''End of Substitute
Next iShape
End With
Next iSlide

End Sub

  #9  
Old January 16th, 2005, 04:17 PM
Jeff Jones
external usenet poster
 
Posts: n/a
Default

LOL. I love to see people comrading.....

Here's the code I've developed thus far.

Sub ChangeHyperLinkData()

Dim oSld As Slide
Dim oAgenda As TextRange
'Stop
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Count
Set oSld =
ActivePresentation.Slides(ActivePresentation.Slide s.Count)

ActiveWindow.Selection.SlideRange.Shapes("Rectangl e 17").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRa nge.Select

With ActivePresentation.Slides(ActivePresentation.Slide s.Count)
Set oAgenda =
ActiveWindow.Selection.ShapeRange.TextFrame.TextRa nge
End With

With oAgenda.Sentences(1) _
.ActionSettings(ppMouseClick).Hyperlink
.Address = "http://www.gsms-am.eds.com/
http://www.gsms-am.eds.com/ "
.TextToDisplay = "Americas: http://www.gsms-am.eds.com
http://www.gsms-am.eds.com " & vbNewLine
.SubAddress = ""
End With
With oAgenda.Sentences(2) _
.ActionSettings(ppMouseClick).Hyperlink
.Address = "http://www.gsms-ap.eds.com/
http://www.gsms-ap.eds.com/ "
.TextToDisplay = "Asia Pacific: http://www.gsms-ap.eds.com
http://www.gsms-ap.eds.com " & vbNewLine
.SubAddress = ""
End With
With oAgenda.Sentences(3) _
.ActionSettings(ppMouseClick).Hyperlink
.Address = "http://www.gsms-ea.eds.com/
http://www.gsms-ea.eds.com/ "
.TextToDisplay = "Europe & Africa: http://www.gsms-ea.eds.com
http://www.gsms-ea.eds.com "
.SubAddress = ""
End With

End Sub

It works fine as long as I open the blank.pot file that contains the
macro. I've added a button to a new toolbar that executes the macro
to the blank.pot file and it is available when I open PowerPoint but
it's not effective until the blank.pot file itself has been opened.

I'm playing with an add-in with the macro in it and can load the
add-in with no problems but the button is still not effective until
blank.pot is opened. Sigh.....

Where I want to end up is to have a macro that will open every
presentation, in turn, in a folder, change the links on the last
slide, and save the presentation.

Do you suppose that I'm sneaking up on my objective? I'm FAR too lazy
to want to make all these changes manually. Besides, it's FAR, FAR
more fun to build a macro to automate tedious tasks.

Thank you all for your help thus far. My beloved is certain that I'm
truly a computer geek and the fact that this wonderfulness if fun
supports my geekness. giggle

Jeff


On Sat, 15 Jan 2005 11:49:42 EST, Steve Rindsberg
wrote:

In article , MS MVP Brian Reilly
wrote:
Jeff,
Here's another piece of code in addition to Steve's that I use all the
time as a wrapper to iterate through all shapes on all slides. Note,
I've commented out the section that you can change exactly what you
do, but the top and bottom parts are the iteration code.


Brian reformats his hard drive quite often. Chances are he lost his mind the
last time he did it. It's one of those pesky hidden files, ya know?

Sub DiddleAllTheShapes()

Dim oSh as Shape
Dim oSl as Slide

' Look at each slide
For Each oSl in ActivePresentation.Slides
' Look at each shape on the slide
For each oSh in oSl.Shapes
' Do whatever you need to with the shape
With oSh
Debug.Print .Name
.Left = .Left + 10
' .Whatever
End With ' The shape
Next ' Shape
Next ' Slide

End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
=============================================== =


  #10  
Old January 16th, 2005, 08:01 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article , Jeff Jones wrote:
LOL. I love to see people comrading.....


The way Brian and I abuse one another, you'd think we're married. ;-)

Sub ChangeHyperLinkData()

Dim oSld As Slide
Dim oAgenda As TextRange
'Stop
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Count
Set oSld =
ActivePresentation.Slides(ActivePresentation.Slide s.Count)


You don't need to go to the slide (ie, to display it) in order to affect it, and
in fact your code will run way faster if you don't.

Set oSld = ActivePresentation.Slides(ActivePresentation.Slide s.Count)

is enough


ActiveWindow.Selection.SlideRange.Shapes("Rectangl e 17").Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRa nge.Select

With ActivePresentation.Slides(ActivePresentation.Slide s.Count)
Set oAgenda =
ActiveWindow.Selection.ShapeRange.TextFrame.TextRa nge
End With


Likewise, you don't need to select anything either. Just this will do it instead
of all the above:

Set oAgenda = oSld.Shapes("Rectangle 17").TextFrame.TextRange


With oAgenda.Sentences(1) _
.ActionSettings(ppMouseClick).Hyperlink
.Address = "http://www.gsms-am.eds.com/
http://www.gsms-am.eds.com/ "


and so on ...

It works fine as long as I open the blank.pot file that contains the
macro. I've added a button to a new toolbar that executes the macro
to the blank.pot file and it is available when I open PowerPoint but
it's not effective until the blank.pot file itself has been opened.

I'm playing with an add-in with the macro in it and can load the
add-in with no problems but the button is still not effective until
blank.pot is opened. Sigh.....


Right. The button is associated with the macro in the original pot file in PPT's
mind. Add an Auto_Open subroutine to the add-in and include code in it to create
any necessary buttons/bars/menus.

Create an ADD-IN with TOOLBARS that run macros
http://www.rdpslides.com/pptfaq/FAQ00031.htm

Where I want to end up is to have a macro that will open every
presentation, in turn, in a folder, change the links on the last
slide, and save the presentation.


Do something to every file in a folder
http://www.rdpslides.com/pptfaq/FAQ00536.htm


Do you suppose that I'm sneaking up on my objective? I'm FAR too lazy
to want to make all these changes manually. Besides, it's FAR, FAR
more fun to build a macro to automate tedious tasks.

Thank you all for your help thus far. My beloved is certain that I'm
truly a computer geek and the fact that this wonderfulness if fun
supports my geekness. giggle

Jeff

On Sat, 15 Jan 2005 11:49:42 EST, Steve Rindsberg
wrote:

In article , MS MVP Brian Reilly
wrote:
Jeff,
Here's another piece of code in addition to Steve's that I use all the
time as a wrapper to iterate through all shapes on all slides. Note,
I've commented out the section that you can change exactly what you
do, but the top and bottom parts are the iteration code.


Brian reformats his hard drive quite often. Chances are he lost his mind the
last time he did it. It's one of those pesky hidden files, ya know?

Sub DiddleAllTheShapes()

Dim oSh as Shape
Dim oSl as Slide

' Look at each slide
For Each oSl in ActivePresentation.Slides
' Look at each shape on the slide
For each oSh in oSl.Shapes
' Do whatever you need to with the shape
With oSh
Debug.Print .Name
.Left = .Left + 10
' .Whatever
End With ' The shape
Next ' Shape
Next ' Slide

End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
=============================================== =



-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.