View Full Version : Referencing different textbox in VBA
mgoblue7
03-20-2009, 04:17 AM
I'm using Office 2007 and I want to know how to reference different textboxes on the same slide in VBA. Attached is the picture of my slide. Thank you.
Paul_Hossler
04-03-2009, 01:59 PM
I have a macro that I use to Name or to re-Name a shape, and then I can refer to it by name
In the attached demo, I named the 5 shapes and the Demo sub will display the captions. Of course, once I have the shape, I can do other things with it
Sub RenameObject()
Dim o As Object
Dim sName As String, sNameNew As String
'if a shape is selected
Set o = Nothing
On Error Resume Next
Set o = ActiveWindow.Selection.ShapeRange(1)
On Error GoTo 0
'no shape selected, so try the active slide
If o Is Nothing Then
On Error Resume Next
Set o = ActiveWindow.Selection.SlideRange(1)
On Error GoTo 0
End If
'guess there's nothing to rename
If o Is Nothing Then Exit Sub
'get the current name
sName = o.Name
'ask for the new name
sNameNew = InputBox("What is the new name?", "Sub: RenameObject", sName)
sNameNew = Trim(sNameNew)
'if the new name is OK then rename the object
If Len(sNameNew) > 0 Then o.Name = sNameNew
End Sub
Sub Demo()
With ActivePresentation.Slides(1)
MsgBox .Shapes("Top").TextFrame.TextRange.Text
MsgBox .Shapes("Problem").TextFrame.TextRange.Text
MsgBox .Shapes("One").TextFrame.TextRange.Text
MsgBox .Shapes("Two").TextFrame.TextRange.Text
MsgBox .Shapes("Three").TextFrame.TextRange.Text
End With
End Sub
Paul
John Wilson
04-05-2009, 02:46 AM
You don't need vba in 2007 to do this. Simply show the selection pane, highlight the name and change it.
Paul_Hossler
04-05-2009, 06:44 AM
Much handier. I would have bet money, that I had seen that once before, but I could never find it again. Did not google the correct term for one thing.
Since I don't usually want to Select All (Ctrl-A works if I need to) I never thought to go down Edit, Select, Selection Pane. I kept looking on View.
I just added that to my QAT.
Any other "pains" added in 2007 that are not obvious or automatic ?
Paul
John Wilson
04-05-2009, 12:16 PM
I totally agree!! I have Selection Pane on the QAT too but I always forget it's there.
Selection pane should be on the view tab and maybe even insert new slide on the insert tab! For me also Manage Add Ins on the Developer tab. What were they thinking of. Maybe I'll write a little Add In to do this. Do people think it would be useful?
Paul_Hossler
04-06-2009, 10:39 AM
Some people might like the add-in. I have a PP .ppam that I keep my general purpose subs in, so I just added a litle XML to that one
<tab idMso="TabView">
<group id = "gSelect" label = "Select" insertAfterMso = "GroupViewShowHide">
<toggleButton idMso = "SelectionPane" size = "large"/>
</group>
</tab>
Hopefully, I won't forget where this handy little tool is again.
Paul
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.