Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Need correct animation, need macros?


Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2012, 09:55 AM
jamtart jamtart is offline
Newcomer
 
Join Date: May 2009
Posts: 14
Default Need correct animation, need macros?


Some knowledge of electrical switching may be needed here. In this Powerpoint presentation what I need is for the lamp to be on when the path is complete and off when the path is not complete. Triggers dont appear to cut it.

It would also be helpful to my students if the completed path were to glow or some indication of the path.

I think this is beyond my expertise, sure hope someone can help me out here.

I have posted this elsewhere for help as well...
Guess I should have specified that this is a Powerpoint in the original post, sorry

Last edited by jamtart; 08-04-2012 at 03:14 PM.
Reply With Quote
  #2  
Old 08-04-2012, 03:06 PM
hDC_0 hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 522
Default VBA (including powerpoint) animations

If you do a forum search for "animations" under the VBA sub forum,
of the VB Classic part of the forum, I think you'll only find about 13 threads,
(mostly dealing with starting and stopping animation in PowerPoint).

I'm not a VBA expert, but I don't think that Excel has native animated gif support,
(and probably most this can be said of the most of the regular VBA apps Word, Access, etc as well).

I would defer to thoughtful answer given on this page:
Quote:
There are several ways to achieve graphic animation in Excel.
But I should qualify first that Excel is not a great application for doing dynamic graphics
since it does not contain any built-in (and therefore efficient) code to support this.
For example, Excel will not animate an animated GIF picture.

With that said, how you go about doing animations in Excel depends on what you want to animate.

If you want an animation based on rapidly changing pictures, like an animated GIF,
this can be done by simply pasting the pictures on a worksheet (or chart)
and using VBA code to rapidly change their Visible properties to make one visible at a time.
Similarly, you can make any kind of graphic object move across the screen by rapidly updating its Top and/or Left properties,
which determine the screen coordinates of the top and left edges
of the object's bounding box, and again, this done with VBA code.
The same thing applies to rotating shape objects by changing the object's Rotation property.

On the other hand, if you want to draw a graphic object, such as a polygon,
and animate in the sense of transforming all the vertices of the object,
this can be done.
For example, it is possible to draw a perspective view of the earth using polygons to represent continents,
and rotate the earth to create a view from any direction.
However, because this requires many polygons,
each having many points, drawing the entire picture from one perspective
takes several minutes and therefore Excel is incapable of animating this.

However, very simple objects involving just a few polygons and dozens of points rather than thousands can be animated fairly effectively.

I should mention that the pre-Excel 97 Drawing objects are still supported by new versions of Excel,
and these objects are more amenable to drawing and animation from VBA than the newer Shape-type drawing objects.
These objects do not ordinarily show up in the VBA helps,
but you can make them visible by opening the Object Browser in the Visual Basic Editor,
right-clicking in an Object Browser window pane,
and selecting Show Hidden Members.
The other way that animated gifs can play within VBA app is embedding a web browser control.
The MSDN article "Handling Events in Visual Basic Applications" includes some info on handling the Web Browser control using VBA.

From your description a set of non-animated gifs (just using a static, but transparent, background might be enough for your purposes.
You would just turn the visibility of the graphic on and off using VBA code.
VBA: Sample VBA Code to Insert an Image
Here is also some code to adds an image to a PPT slide at runtime.
Here is some code to hide a powerpoint presentation shape image at runtime

A "glow" would be relatively involved effect to achieve.

Gif files do not support alpha opacity gradients (only single color value transparency).
PNG files are not well support in a VBClassic (VB6) context.
Probably your best bet, if you are using a fixed single background color is to
create the graphics-with-glow at design time inside a graphics program like Photoshop
then save as a bitmap for use as an Image in your VBA project.

Re: Runtime per pixel VBA drawing
I know in PSet is supported in Access 2003, but tends to be slow in drawing large amounts of pixels.

You can use APIs like GetPixel and SetPixel in VBA but it prevents
some difficulties since the Image object doesn't give full access to a device context.

I found some VBA code for flipping through images.
Here's the setup instructions:
Quote:
Place all you images on a Userform, each set in an "Image" Control, also place a CommandButton on the userform. (This code shows CommandButton1)
Double click your "Userform" in design Mode and paste the code Below into the window.
NB:- The option Explicit, Variable "Num"
Here's the code:
Code:
Option Explicit
Dim Num As Integer

Private Sub CommandButton1_Click()
Dim pic As Control, c
Static temp
c = 0
If temp = Num Then temp = 0
    For Each pic In Me.Controls
        If TypeName(pic) = "Image" Then
            c = c + 1
                If pic.Visible = True Then
                    pic.Visible = False
                    temp = c
                End If
If pic.name = "Image" & temp + 1 Then pic.Visible = True
End If
Next pic
End Sub

Private Sub UserForm_Initialize()
Dim pic As Control
For Each pic In Me.Controls
    If TypeName(pic) = "Image" Then
        pic.Visible = False
        Num = Num + 1
    End If
Next pic
End Sub
When you click the Button each picture should be displayed in turn.

Other than that, someone who is a VBA expert, may post a little later and be able to help you more..

Last edited by hDC_0; 08-04-2012 at 03:43 PM.
Reply With Quote
  #3  
Old 08-04-2012, 03:15 PM
jamtart jamtart is offline
Newcomer
 
Join Date: May 2009
Posts: 14
Default

I edited my post to indicate that this is a powerpoint presentation, sorry, I should have stated that first time round...
Reply With Quote
  #4  
Old 08-06-2012, 08:08 AM
jamtart jamtart is offline
Newcomer
 
Join Date: May 2009
Posts: 14
Default

I got this one to work without macros, Mod may delete post if need be, thank you
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->