How to implement disappearing animations in VBA? - vba

I'm trying to test effect animations on shapes in a VBA procedure.
I've already achieved one which is adding some new animations in the MainSequence, defining in which position in the Timeline... but I am not able to create disapearing animations.
I checked in the beginning of the code some already there...and the EffectType seems to return the same value as related appearing animation, so that I sadly believe there's no way of creating disapearing animations in VBA.
Please tell me I am wrong, I have to do the same creations on over 300 slides...

Yes, you are wrong, however documentation to that is... well, I guess you know that already.
Here's the trick. To add a disappearing animation you have to add appearing animation but set it's 'Exit' property to 'msoTrue'
Take a look at this code example:
Private Sub SetAnimation()
Dim effNewEffect As Effect
With ActiveWindow.View.Slide
Set effNewEffect = .TimeLine.MainSequence.AddEffect(.Shapes(.Shapes.Count), msoAnimEffectAppear, trigger:=msoAnimTriggerWithPrevious, Index:=-1)
End With
effNewEffect.Timing.TriggerDelayTime = 1.0
effNewEffect.Exit = msoTrue
End Sub
It will add a Disappear animation to the last Shape in a current slide as the last in the MainSequence with delay 1.0 s to the previous animation.

The solution I found is to use an "Exit" property on the "Effect" object.
The "Exit" property is msoFalse by default.

Can't believe I have the answer to anything but here goes.
Select object to disappear
Go to animations an select fade out (red one)
Open animation pane
go to the click down menu for the object
Select Effect options
Go to timing menu
Click triggers
Click "start effect on click of" and find the object number that matches the one on the animation panel for it.
Job done.

Related

How to resize an access form to fit the screen

So I've recently upgraded from Access 2003 to Access 2016 and of course, I hate having to deal with the obnoxious white background that can not be changed in 2016. Maximizing forms/reports is not an option for us as we oftentimes will be using multiple forms/reports at any given time and need to be able to view and change between them to do our job.
I've come up with what I think is a pretty smart solution, I created a background form that is empty except that it has a dark gray background to make it easier on your eyes. When you open a new form or report (On Open Event), it then places that form on top of a stack so that you have a hierarchy of open forms and reports.
Should you click on a form or report that isn't on top (On Activate Event), then it gets moved back to the top of the stack. Then should you accidentally click on the background form, instead of covering up everything you've been working on, it goes through the stack, starting at the bottom and setting focus to each form or report in order. Here's how I do it for those of you interested:
Private Sub Form_GotFocus()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT ID, FormName, FrmRpt FROM FormStack ORDER BY ID", dbOpenSnapshot)
If rst.EOF Then
DoCmd.OpenForm "frmMenu"
Else
While Not rst.EOF
If rst.Fields("FrmRpt") = "Form" Then
Forms(rst.Fields("FormName")).SetFocus
Else
DoCmd.SelectObject acReport, rst.Fields("FormName")
End If
rst.MoveNext
Wend
End If
rst.Close
Set rst = Nothing
End Sub
This is all working perfectly, I just need to make sure I add the code to any new forms or reports that I create.
So here is my dilemma, this background form needs to be big enough to fill the screen of whoever is using it, otherwise, you would see white around the edges. Since everyone has different monitors I decided to make the form extremely large (21"x13") so that it would fill the screen of anyone who is using it. I have Auto Center, Auto Resize, and Fit To Screen all set to yes.
I have No border, record selectors, navigation buttons, diving lines, scroll bars, control boxes, close buttons, or min-max buttons, and it also is not moveable. The Detail section can grow and can shrink. So now everything is working, except since this form is bigger than anyone's Access window, there are now scroll bars on the Access window itself so that you can move around to see the whole background form in all of its drab, dark gray glory.
It would be great if it could be fit to fill the Access window perfectly so that these scroll bars won't appear and confuse users.
Does anyone know how to solve this problem?
Go to Access settings=> document window options and select tabbed documents. Any form you want to have specific size, you can then set as "popup".
You can still have your custom form with custom bg colour, size 1cmx1cm, no scroll, no navigation bar, no record selctor, borderstyle none. Place a rectangle and set the Anchoring property to "strech down and across" that'll fill the whole access app and user won't be able to close it.
settings page
sample result
I would
Maximize the background form to cover the Access background.
Set all Forms+Reports to Popup = Yes, then they won't be maximized, even if a maximized form is open.
Educate the users that they now have more freedom where to move the windows, and that they should avoid covering the menu bar.
If some of them have a two-monitor setup, they can also move some windows to the 2nd monitor (outside the Access main window). This can be very useful.
(And most importantly) do away with all this code in all forms.
Late answer, but best solution I've found is Shrinker-Stretcher over at Peter's Software. It cycles through all controls and resizes everything on a form (and its subforms) to fit the application window. Developer's license is reasonable for what it does.
Well this doesn't resize a form to fit the screen, but Access now has a Dark Gray theme which gives me a dark background and solves my problem.

Draw border around controls on VBA Userform without using a Frame?

I am designing a VBA UserForm (in Excel, if it is relevant) and I would like some controls to be visually grouped together.. but when I put them in a frame, I am getting some undesired results (part of it has to do with the RefEdit control which seems to be particularly unhappy inside a frame).
Is there a way to draw a border around a group of controls on a form without putting them inside a Frame?
Use a label with the caption deleted and the border style set to fmBorderStyleSingle. It may appear on top of your other controls, so right click on it and select "send backwards" until it's behind your other controls.
The best way to do this would be to create the shape over where you need it to be. Drag highlight everything that you want on top of it, then right click and brink it all forwards. Then when you drag your shape back over the top it will in fact be underneath everthing else.
Hope that helps.
This worked for me and I was at first having the same issue where I had to choose to "Send Backward" up to 30 times per label in some cases. I found that hitting the Ctrl-K sends it to the back of all controls with one time hitting these keys.

Issues with event created buttons not aligning as expected

new bloke having issues again.I have a button on a form which is set to create another button in it's current location, then using a timer that runs
button.top = button.top + 10
for every tick, the design created (aka button creator) button moves down to just under the new button, and in the same alignment. Due to the size of the form I'm working on, once this has been done 3 times, the creator button is now askew, slightly to the right of the added buttons above it, rather than than in the same place, due to the controls now extending past the form size and the scrollbar becoming visible.
I've done some searching around, but so far the answers I have found haven't helped - probably more due to me not understanding correctly - and it's starting to do my head in because it should logically be so simple.
I thought I'd figured out the issue this evening when I realised that it's the previously added buttons which are moving from
location.x = 100
to
location.x = 91
and not the creator button changing it's habits.
Can anyone point out what is probably something so simple that I am overlooking in order to get these aligned?
Thanks in advance.
instead of using the location.x property try using LEFT property of the object...
so when you create the NEW button and set its inital position use the ThisButton.Left = Value to position it....
where ThisButton is the NAME of your button
and Value is the X location numeric value.

How to auto advance a PowerPoint slide after an exit animation is over?

PowerPoint entrance animation set up with "Start: With Previous" starts right when a new slide is advanced. However, if you set up an exit animation in the same way, it doesn't start with a slide ending sequence. Instead, the "Start: On Click" trigger needs to be used and after your exit animation is over you still need one extra click just to advance to the next slide.
Workarounds to this are obvious: create a duplicate slide, make your ending animations from the original slide being your starting animations on the duplicate slide and let them be followed with whatever you want or create a transition slide with those ending animations only and set up "Change Advance slide -> Automatically after -> [the time it takes your animations to finish]".
These workarounds will make it work for your audience, visually. However, it has an impact on slide numbers you might need to adjust accordingly and/or duplicate content changes. If you are the only one creating and using your presentation, this might be just fine. But if you are creating a presentation in collaborative mode with three other people and don't even know who will be the presenter at the end, you can mess things up.
Let's be specific: most of my slides have 0.2s fly in entrance animation applied to blocks of content coming from right, bottom or left. Advancing to the next slide I want them to fly out in another 0.2s exit animation being followed by new slide 0.2s fly in entrance animation of the new blocks. The swapping of the blocks should be triggered while advancing to the next slide, as usually.
As mentioned, I'm not able to achieve this without one extra click between the slides.
I wrote a VBA script that should start together with an exit animation and will auto advance a slide after 0.3s when the exit animation is over. That way I should get rid of those extra clicks which are needed right now.
Sub nextslide()
iTime = 0.3
Start = Timer
While Timer < Start + iTime
DoEvents
Wend
With SlideShowWindows(1).View
.GotoSlide (ActivePresentation.SlideShowWindow.View.Slide.SlideIndex + 1)
End With
End Sub
It works well when binded on a box, button or another object. But I can't make it run on a single click (anywhere on the slide) so that it could start together with the exit animation onclick trigger. Creating a big transparent rectangular shape over the whole slide and binding the macro on it doesn't help either. By clicking it you only get the macro running, exit animation is not triggered.
Anyway, I don't want to bind the macro to any other workaround object but the slide itself.
Anyone knows how to trigger a PowerPoint VBA script on slide onclick event?
Anyone knows a secret setting that will make the exit animation work as expected i.e. animating right before exiting a slide while transitioning to the next one?
Anyone knows how to beat this dragon?
Thank you!
You could also set the TRANSITIONS (tab) -> Advance Slide After 00:00:00 seconds. You will need to set the SLIDESHOW (tab) to Use (Rehearsal) Timings. This will automatically advance the slide after the last animation action. You could, of course give it some seconds to wait, but it sounds like you just want to advance the slide.
You can intercept events in powerpoint using class module
In Class Module
In left combo (object) in VBA Explorer you can see ppt and in right your events
Private WithEvents ppt As PowerPoint.Application
In common module use
set x= new class1
Now you can use all events of presentation.
[]'s
OnSlideShowPageChange: VBA working while going to a slide without pressing any button
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = SSW.Presentation.Slides(x).SlideIndex Then
'PUT CODE HERE
End If
End Sub
Theire is a code havy workaround
You do that using the duplicate methode. However you duplicate using vba not manualy.
You can use the OnSlideShowPageChange
Test if the slide is one that need to be duplicated using a naming scheme of your choice. Then duplicate the slide. Then set the trasition effect to non and make it transition after 0 sec duration. Then remove all animations and add the exit animations desired.
Then you use the SlideShowEnd event to delete all the duplicate slides.
Note that you can use the SlideShowBegin to duplicate all the slides at once however duplicating a slide is not a fast tasck. So if you have a lot of havy slides to duplicate strating you presentation may take few seconds.
Sorry for not providing the code since it needs several lines.
For naming the slides you use also a macro.

Picture box goes blank

In VisualBasic.Net When I activate a picture box and then draw something on it, it draws and then immediately goes blank. Works fine when I re-draw it, but almost always messes up the first time I draw on it. This has happenned with several different programs, and the help file is no help.
Try setting the DoubleBuffered property
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx
If that's not it, please provide more info.
Usually, if you're drawing something on a picture box or on another control, you have to take over the OnPaint event, and you're responsible of persisting what you draw on this event.
Thank you Andrew, but no help. I'm using .Net Framework 1.1, which does not offer the DoubleBuffered property... it was new in 2.0.
Not sure what additional info to provide.. the code is 300 lines long. When a button is clicked, the code expands my form, makes two picture boxes visible (one on top of the other (the back one is for some graph labels), and then uses some graphic brushes and pens to draw a graph on the front box. There's some database activity and calculations going on in the background at the same time.
I assume you're using the standard PictureBox component. Do you draw in the Paint-Handler? If not then the PictureBox will just erase your painted stuff next time it's asked to redraw itself (erase background etc.).
Yes, I believe I am using the standard picture box.
By Paint-Handler, I assume you mean a [Control].PaintEvent Handler. No I'm not using an event handler to do the drawing... drawing my chart is not an event in itself, but part of a much larger response to a button click event.
If you are saying that having the drawing code be part of a separate and specific handler can solve my problem, than I guess I could raise an internal event every time I want to redraw the chart. But I Would rather just figure out what is causing the PB to redraw itself without being told to.
If you cannot use the DoubleBuffered than you can HIDE a second picture box. You do the drawing in it and once it's completed you draw back to the VISIBLE one. This way the process of drawing is done on the hidden one and the white/flickering will not be shown.