|
-
Dec 7th, 2004, 03:18 PM
#1
Thread Starter
New Member
Problems with the events caught by DoEvents and/or SlideShowNextSlide
Hi all,
I'm currently working on an add-in for Powerpoint.
What I want to do is basically to send the title of the slides to a website during the slideshow.
For now, I have been able to do that but it appeared that it takes some time for the http calls, so I'd like to limit the sending to slides on which I stay for more than one second. (to allow to go quickly back and forth in the slideshow to find a slide for example)
So, I have this function:
Code:
Function Delay(nbSeconds As Double) As Boolean
Const OneSecond As Double = 1# / (1440# * 60#)
Dim endTime As Date
endTime = Now + OneSecond * nbSeconds
Do Until Now > endTime
Sleep 100
DoEvents
Loop
End Function
and in App_SlideShowNextSlide, I have:
Code:
index = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
Delay 1
If (index = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex) Then
MsgBox "send the title"
Call SendTitleFunction
End If
I have added the value 'index' because I haven't been able to stop the other function if the slide changes before the one second delay. So it checks if the slide has changed or not during the second.
If I go to the next slide with a click or the enter key, it's okay: I only send the correct one and I can go fast to a specific slide.
But if I use the arrows or next page or the space bar, I have to wait for the whole second: it seems that DoEvents don't catch these events.
Then to go backward I have to use the arrow or Previous Page, and I have to wait again (and to send the title...).
So, my questions are:
-is my assumption about DoEvents correct? and if so, is there a way to catch all slide changes?
-how could I tell to the Delay calls to stop once I change the current slide again to start another call? it seems that I have as many threads as slides changes in one second. I'm not sure that's good.
Thanks for your help!
R.
-
Dec 7th, 2004, 05:00 PM
#2
Re: Problems with the events caught by DoEvents and/or SlideShowNextSlide
Welcome to the Forums.
With the issue about #2, you can add a module level boolean variable that
you will check in the do loop. If it is true then you exit the do/procedure. If
its false then continue to wait. The way to set it would be in the KeyPress or
KeyDown events. But without seeing all your code I cant be certain which
event would be best.
The issue with #1 may be from the Sleep API call.
HTH
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 7th, 2004, 07:10 PM
#3
Thread Starter
New Member
Re: Problems with the events caught by DoEvents and/or SlideShowNextSlide
Thanks for welcoming and helping!
Actually, I have tried something like that and it didn't work. But, I'm a little confused about the behaviour of VBA with the different calls to the same function so I may have made a mistake.
The following code si the whole code included in a classe.
Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public WithEvents App As Application
Dim stopDelay As Boolean
Private Sub App_SlideShowNextSlide(ByVal wn As SlideShowWindow)
Dim index As Integer
index = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
stopDelay = True ' not sure at all of that
Sleep 110 ' .....................
stopDelay = False '......................
Delay 1, index
End Sub
Function Delay(nbSeconds As Double, indexS As Integer) As Boolean
Const OneSecond As Double = 1# / (1440# * 60#)
Dim endTime As Date
endTime = Now + OneSecond * nbSeconds
Do Until Now > endTime
If (stopDelay) Then
Exit Function
End If
Sleep 100
DoEvents
Loop
Call SendTitleFunction
End Function
As I've written in the comment, I'm not sure at all of that, because I don't understand how VB manage the different calls to this class: basically, I don't know if the variable stopDelay is the same for all or not...
If it can help you better to see what I mean...
Thanks.
R.
-
Dec 7th, 2004, 09:24 PM
#4
Re: Problems with the events caught by DoEvents and/or SlideShowNextSlide
Ironic, Jacob Roman just posted some code in CodeBank that is sure to improve
the basic DoEvents for you. Look here.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Dec 8th, 2004, 07:54 PM
#5
Thread Starter
New Member
Re: Problems with the events caught by DoEvents and/or SlideShowNextSlide
Concerning the issue #2, I have finally done something which seems quite clean to me:
Code:
Private Sub App_SlideShowNextSlide(ByVal wn As SlideShowWindow)
Dim index As Integer
index = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
Module1.nbDelays = Module1.nbDelays + 1 'nbDelays is a global boolean
Delay 2
If Module1.nbDelays = 0 Then
Call SendTitle
End If
End Sub
Function Delay(nbSeconds As Double) As Boolean
Const OneSecond As Double = 1# / (1440# * 60#)
Dim endTime As Date
endTime = Now + OneSecond * nbSeconds
Do Until Now > endTime
Sleep 100
DoEvents
Loop
Module1.nbDelays = Module1.nbDelays - 1
End Function
I don't really stop the other functions but it was not the real problem.
Concerning the other one, the one that matters to me I have followed your link and tried a little bit two of the functions mentionned: GetInputState and GetQueueStatus.
My computer crashed so I have lost it but it wasn't working as far as I remember. I will read the article again and try to eventually make it work...
BTW, do you know (it should maybe be a new topic) if there is a difference between VBA on Mac & Windows concerning the menu items? My Auto_Open function adds an item in the Tools menu but that doesn't work on a Mac although the addin is loaded.
Should I rewrite the addin in a Mac environment?
Thanks a lot for your help!
Raspoutim
-
Dec 8th, 2004, 09:21 PM
#6
Re: Problems with the events caught by DoEvents and/or SlideShowNextSlide
The link with the advanced DoEvents equilivalent, I'll admit, I have not tested out.
I have never developed anything for MAC, or seen the MAC version of Office.
I would cautiously "assume" that the event my not be firing due to
compatibility issues. So yes I would suggest that you develop OS platform
handeling for either MAC or Windows.
Start with a small test project to re-affirm the assumption so if its wrong,
your not wasting too much time. Could you post back or PM me if you find out?
Thanks.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|