Powerpoint 2003 VBA subroutine

T

Tom Conrad

I have a PPT 2003 slide show, that uses vba controls to allow the user to
dynamically change the rotation angles of two objects on a single slide,
during the presentation.

The rotation angle for one object is controlled by a spinbutton, while the
rotation angle for the second object is controlled by a spinbutton. The value
for each control is determined by two discrete subroutines, one each for the
spinbutton, and for the scrollbar. The subroutines are embedded to the slide.

Within each subroutine are identical command sequences to redraw the screen
objects at the rotation angles set by the control variables.

Since the command sequences are identical I want to compress my code by
creating a single subroutine which can be accessed by either the spinbutton
or scrollbar primary routines.

How do I create a jump, call or loop to my redraw procedure?
 
T

Tom Conrad

Austin,

After scrubbing my proprietary data. I figured out my problem.

I had declared my variables within specific subroutines. For example in
subroutine 1, I declared a variable "dim radial as long". I wanted to use the
radial value within subroutines 1, 2 and 3, however, by only declaring the
variable within sub 1, I blocked the use of the variable to subs 2,3. When I
moved the variable declarations outside of the subroutines, then my problem
was solved.

I was then able to place repetitive code into a single module that could be
called by other the subroutines.
 
A

Austin Myers

Glad you got it sorted Tom.



Tom Conrad said:
Austin,

After scrubbing my proprietary data. I figured out my problem.

I had declared my variables within specific subroutines. For example in
subroutine 1, I declared a variable "dim radial as long". I wanted to use
the
radial value within subroutines 1, 2 and 3, however, by only declaring
the
variable within sub 1, I blocked the use of the variable to subs 2,3. When
I
moved the variable declarations outside of the subroutines, then my
problem
was solved.

I was then able to place repetitive code into a single module that could
be
called by other the subroutines.
 
B

Brian Reilly, MVP

Tom, Good for you sorting it out. Here are a few additional comments
for the future.
If you use Dim in a module outside the Sub's then those variables are
available to anything in that module.
If you declare variables as Public they are available to all modules.
e.g. Public dteNow As Date
You also might want to look into using Constants if you are using the
same variable to a value in lots of places.

Brian Reilly, MVP
 

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