Naming Textboxes in PowerPoint (via VBA)

J

Jackie

I have a presentation (.pot) file that I am using as my main presentation,
through code I am able to insert different information depending on the
user's requirements. To place the information in the presentation I have
named some of the textboxes in the pot file.

My query is that naming the textboxes etc does not always work and I am
unsure why. To name the textboxes I am opening the pot file, and through
immediate window, am analysing the shapes and then when I find the textbox I
require I use the .Name option to rename.

Any ideas why this is not consistent?

Many thanks
Jack
 
B

Bill Foley

Insert this code into a module and/or put it on a toolbar icon so it is
always available:

'=====Code Starts here=====

Sub NameShape()
Dim Name$
On Error GoTo AbortNameShape

If ActiveWindow.Selection.ShapeRange.Count = 0 Then
MsgBox "No Shapes Selected"
Exit Sub
End If
Name$ = ActiveWindow.Selection.ShapeRange(1).Name

Name$ = InputBox$("Give this shape a name", "Shape Name", Name$)

If Name$ <> "" Then
ActiveWindow.Selection.ShapeRange(1).Name = Name$
End If
Exit Sub

AbortNameShape:
MsgBox Err.Description

End Sub

'=====Code Stops Here=====
 
J

Jackie

Thanks for this Bill.

This is the equivalent of how I am naming the textboxes in the immediate
window. (Activepresentation.Slides("Peopleslide").Shapes(7).Name = "Date").
The issue I have is that I am able to change some of the textboxes this way
but not all. I identify the textbox I require (in this case "Shapes(7)")
rename to "Date", check
(?Activepresentation.Slides("Peopleslide").Shapes(7).Name) to ensure it has
changed. Save the pot file, reopen and the name has reverted back to the
original (in this case Text Box 23).

I have three text boxes on the slide, I have managed to change the first
this way but not the second or third. I have also managed to change the name
of the slides using the immediate window. I cannot understand why this is not
consistent? Any ideas?

Many thanks
Jackie
 
D

David M. Marcovitz

It might be easier to use the currently selected shape to rename. The
reason for using shape names is probably the reason you are having
trouble. Shape numbers are a little flaky and ephemeral. Try Bill's code
(or the code in Example 8.7 at my site:
http://www.loyola.edu/education/PowerfulPowerPoint/) with selected shapes
and see if that works for you. That eliminates the need to know shape
numbers because you are simply naming the selected shapes.
--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
J

Jackie

Thanks David. I took your advice and used the Select option but still found I
had the same problem. After some investigation I have learnt that the shapes
did not rename if I selected the "Save" option but did rename if I selected
"Save As" and overrode the original file.

Regards
Jackie

PS: For your information I have your book sitting right next to me on my desk.
 
D

David M. Marcovitz

That's strange. I have not seen that before. Is your file set to Read-
Only? Have you turned Fast Saves off (I haven't heard of this being the
culprit for something like this, but it is always a good idea to turn it
off)? Are other changes to your file being saved with a regular save?
I'm stumped. Perhaps someone else has seen this before.
--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
S

Shyam Pillai

Jackie,
I've experienced this several times in the past, the best way to resolve
this is save this presentation under a new name or to roundtrip it with a
Save as Webpage and bring it back as PPT, this forces creation of a new file
without any extraneous information.


--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how
 
J

Jackie

Thanks for the reply. I have checked PowerPoint and did have "Allow Fast
Saves" selected. I then went through testing - once saving the names with
"Fast Saves" selected and once saving the names with "Fast Saves" deselected.
The names did not retain their value when "Allow Fast Saves" was selected but
did retain their value when "Allow Fast Saves" was deselected.

I have now deselected "Allow Fast Saves" as it seems to have solved the
problem.

Many thanks
Jackie
 

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