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..