MichaelB1969
09-10-2008, 03:30 PM
Would very much appreciate some advice here. I am trying to embed an ROI calculator within a PPT so that when a presenter is giving the presentation, they can enter values along the way and have it spit out an ROI calculation at the end.
I am just testing a basic L * W = A formula now in order to learn the basics. It works when everything is on one slide. However, when I move the calculate button and the text box containing the answer to the second slide, and then change the code so that it references the values in the text boxes in Slide 1, it doesn't work.
So...
In slide 1, I have two text boxes that I created from the control toolbox. They are:
TextBox1
TextBox2
In slide 2, I have one text box for the answer, and a calculate button, labeled:
TextBox3
Calculate
My VBA, which is written for slide 2, looks like this:
Private Sub Calculate_Click()
Dim L As Single
Dim W As Single
Dim A As Single
L = ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text
W = ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange.Text
A = L * W
TextBox3.Text = A
End Sub
It doesn't work, and I have tried multiple things. Anyone have any ideas? When I debug, it doesn't like the line beginning with L=, so I assume it can't reference the object in the first slide.
One of the things I did try is to replace the (1) and (2) next to Shapes to (TextBox1) and (TextBox2), as well as ("TextBox1") and ("TextBox2"). Don't really know what I am doing here, so I was trying anything I could.
Thanks,
Mike
I am just testing a basic L * W = A formula now in order to learn the basics. It works when everything is on one slide. However, when I move the calculate button and the text box containing the answer to the second slide, and then change the code so that it references the values in the text boxes in Slide 1, it doesn't work.
So...
In slide 1, I have two text boxes that I created from the control toolbox. They are:
TextBox1
TextBox2
In slide 2, I have one text box for the answer, and a calculate button, labeled:
TextBox3
Calculate
My VBA, which is written for slide 2, looks like this:
Private Sub Calculate_Click()
Dim L As Single
Dim W As Single
Dim A As Single
L = ActivePresentation.Slides(1).Shapes(1).TextFrame.TextRange.Text
W = ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange.Text
A = L * W
TextBox3.Text = A
End Sub
It doesn't work, and I have tried multiple things. Anyone have any ideas? When I debug, it doesn't like the line beginning with L=, so I assume it can't reference the object in the first slide.
One of the things I did try is to replace the (1) and (2) next to Shapes to (TextBox1) and (TextBox2), as well as ("TextBox1") and ("TextBox2"). Don't really know what I am doing here, so I was trying anything I could.
Thanks,
Mike