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  

Error using vba



 
 
Thread Tools Display Modes
  #1  
Old November 21st, 2009, 10:32 PM posted to microsoft.public.powerpoint
Wayne[_16_]
external usenet poster
 
Posts: 1
Default Error using vba

I am new at VBA and trying to use VBA in powerPoint 2007 in a vista os
to create a quiz. I am reading a set of question into an array of
questions from a file and want to add one question at a time to a text
box. I am using the following code:
ActivePresentation.Slides(5).Shapes("TextBox
19").TextFrame.TextRange.Text = question(number)

but I have been getting the following error:

Run-time error '-2147188160 (80048240)':

Item TextBox 19 not found in the Shapes collection.

But when I check the object code using either the selection and
visibility option in powerPoint or the code from example 8 from David
Marcovitz

Public Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

I get that the object name is TextBox 19.

Please Help
  #2  
Old November 22nd, 2009, 08:08 AM posted to microsoft.public.powerpoint
Bill Dilworth
external usenet poster
 
Posts: 1,455
Default Error using vba

VBA can be picky. Is there a space between the Textbox part and the 19 part
of the object name?

Bill Dilworth


"Wayne" wrote in message
...
I am new at VBA and trying to use VBA in powerPoint 2007 in a vista os
to create a quiz. I am reading a set of question into an array of
questions from a file and want to add one question at a time to a text
box. I am using the following code:
ActivePresentation.Slides(5).Shapes("TextBox
19").TextFrame.TextRange.Text = question(number)

but I have been getting the following error:

Run-time error '-2147188160 (80048240)':

Item TextBox 19 not found in the Shapes collection.

But when I check the object code using either the selection and
visibility option in powerPoint or the code from example 8 from David
Marcovitz

Public Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

I get that the object name is TextBox 19.

Please Help



  #3  
Old November 22nd, 2009, 08:30 AM posted to microsoft.public.powerpoint
John Wilson
external usenet poster
 
Posts: 6,023
Default Error using vba

If you have not renamed it the name is probably TextBox19 (no space)

I would rename to something more useful in the selection / visibility pane
though
--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoi...tutorials.html






"Wayne" wrote:

I am new at VBA and trying to use VBA in powerPoint 2007 in a vista os
to create a quiz. I am reading a set of question into an array of
questions from a file and want to add one question at a time to a text
box. I am using the following code:
ActivePresentation.Slides(5).Shapes("TextBox
19").TextFrame.TextRange.Text = question(number)

but I have been getting the following error:

Run-time error '-2147188160 (80048240)':

Item TextBox 19 not found in the Shapes collection.

But when I check the object code using either the selection and
visibility option in powerPoint or the code from example 8 from David
Marcovitz

Public Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

I get that the object name is TextBox 19.

Please Help
.

  #4  
Old November 23rd, 2009, 02:07 PM posted to microsoft.public.powerpoint
David Marcovitz
external usenet poster
 
Posts: 647
Default Error using vba

As John and Steve suggested, you might be missing something with the spaces
and as John suggested, you might try to use the SetObjectName macro (in
Example 8.7) to give it your own name so you are sure exactly what it is.
The other problem I could see is if you are really doing all of this on a
different slide than Slides(5). Perhaps, you are working with a different
slide.
--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland

On 11/21/09 5:32 PM, in article
, "Wayne"
wrote:

I am new at VBA and trying to use VBA in powerPoint 2007 in a vista os
to create a quiz. I am reading a set of question into an array of
questions from a file and want to add one question at a time to a text
box. I am using the following code:
ActivePresentation.Slides(5).Shapes("TextBox
19").TextFrame.TextRange.Text = question(number)

but I have been getting the following error:

Run-time error '-2147188160 (80048240)':

Item TextBox 19 not found in the Shapes collection.

But when I check the object code using either the selection and
visibility option in powerPoint or the code from example 8 from David
Marcovitz

Public Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

I get that the object name is TextBox 19.

Please Help



  #5  
Old November 25th, 2009, 03:59 AM posted to microsoft.public.powerpoint
Phil K
external usenet poster
 
Posts: 27
Default Error using vba

Don't mean to hijack this but I figured the problem is similar:
I've read David's book, looked at other examples and I keep getting the
following

Compile Error ... Method or Data Member not found
And the word Shapes is highlighted in blue
for the following.\:
Private Sub CommandButton1_Click()
ActivePresentation.SlideShowWindow.View.Shapes("Pi cture4").Visible = False
End Sub

I've placed a space between picture and 4 and still same error.

I'm trying to make the Shape disappear in VBA. Since it is part of an
overall VBA program. I can animate it but I need to do using VBA. I am
using PPT 2003 with Vista

"David Marcovitz" wrote:

As John and Steve suggested, you might be missing something with the spaces
and as John suggested, you might try to use the SetObjectName macro (in
Example 8.7) to give it your own name so you are sure exactly what it is.
The other problem I could see is if you are really doing all of this on a
different slide than Slides(5). Perhaps, you are working with a different
slide.
--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland

On 11/21/09 5:32 PM, in article
, "Wayne"
wrote:

I am new at VBA and trying to use VBA in powerPoint 2007 in a vista os
to create a quiz. I am reading a set of question into an array of
questions from a file and want to add one question at a time to a text
box. I am using the following code:
ActivePresentation.Slides(5).Shapes("TextBox
19").TextFrame.TextRange.Text = question(number)

but I have been getting the following error:

Run-time error '-2147188160 (80048240)':

Item TextBox 19 not found in the Shapes collection.

But when I check the object code using either the selection and
visibility option in powerPoint or the code from example 8 from David
Marcovitz

Public Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

I get that the object name is TextBox 19.

Please Help



.

  #6  
Old November 25th, 2009, 01:55 PM posted to microsoft.public.powerpoint
David Marcovitz
external usenet poster
 
Posts: 647
Default Error using vba

Is the shape a regular AutoShape or a control shape? I think all our answers
were assuming that it was a regular AutoShape, but a control shape would act
differently and explain the problems.
--David

On 11/24/09 10:59 PM, in article
, "Phil K"
wrote:

Don't mean to hijack this but I figured the problem is similar:
I've read David's book, looked at other examples and I keep getting the
following

Compile Error ... Method or Data Member not found
And the word Shapes is highlighted in blue
for the following.\:
Private Sub CommandButton1_Click()
ActivePresentation.SlideShowWindow.View.Shapes("Pi cture4").Visible = False
End Sub

I've placed a space between picture and 4 and still same error.

I'm trying to make the Shape disappear in VBA. Since it is part of an
overall VBA program. I can animate it but I need to do using VBA. I am
using PPT 2003 with Vista

"David Marcovitz" wrote:

As John and Steve suggested, you might be missing something with the spaces
and as John suggested, you might try to use the SetObjectName macro (in
Example 8.7) to give it your own name so you are sure exactly what it is.
The other problem I could see is if you are really doing all of this on a
different slide than Slides(5). Perhaps, you are working with a different
slide.
--David

--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland

On 11/21/09 5:32 PM, in article
, "Wayne"
wrote:

I am new at VBA and trying to use VBA in powerPoint 2007 in a vista os
to create a quiz. I am reading a set of question into an array of
questions from a file and want to add one question at a time to a text
box. I am using the following code:
ActivePresentation.Slides(5).Shapes("TextBox
19").TextFrame.TextRange.Text = question(number)

but I have been getting the following error:

Run-time error '-2147188160 (80048240)':

Item TextBox 19 not found in the Shapes collection.

But when I check the object code using either the selection and
visibility option in powerPoint or the code from example 8 from David
Marcovitz

Public Sub GetObjectName()
If ActiveWindow.Selection.Type = ppSelectionShapes _
Or ActiveWindow.Selection.Type = ppSelectionText Then
If ActiveWindow.Selection.ShapeRange.Count = 1 Then
MsgBox (ActiveWindow.Selection.ShapeRange.Name)
Else
MsgBox ("You have selected more than one shape.")
End If
Else
MsgBox ("No shapes are selected.")
End If
End Sub

I get that the object name is TextBox 19.

Please Help



.


--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland


 




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 05:29 PM.


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