PowerPoint VBA - some pieces of code runs not in order (MsgBox, Sleep etc) -


vba - 7.1. powerpoint 2013

i trying achieve small animation image on slide (hide - wait half sec - show).

i had noticed earlier msgbox pops before previous line of code gets executed. while annoying, did't bother much. however, same behavior sleep making approach falls apart. don't know how system process management (or threads or whatever) done internally powerpoint seems have problem.

i have tried following far

1:

public declare ptrsafe sub sleep lib "kernel32" (byval dwmilliseconds longptr)  sub sleeptest() activepresentation.slides("slide 1").shapes("worker").visible = 0 sleep 5000 'delay in milliseconds activepresentation.slides("slide 1").shapes("worker").visible = 1 end sub  

resut:-> nothing happens. before visibility set 0, sleep kicks in, wait 5 seconds, image hides , shows within millisec (so cant see happened)

2:

public declare ptrsafe sub sleep lib "kernel32" (byval dwmilliseconds longptr)  sub sleeptest() activepresentation.slides("slide 1").shapes("worker").visible = 0 msgbox("temptemptemp") sleep 5000 'delay in milliseconds activepresentation.slides("slide 1").shapes("worker").visible = 1 end sub 

result: -> msgbox pops immediately, after few seconds while msgbox shown, image hides, click ok, application waits 5 secs, image shown back.

3:

i tried putting hiding , showing steps in 2 different subs , tried calling second sub after sleep. showed same behavior first attempt.

can provide explanation behavior? or suggest other way achieve trying for.


Comments