Results 1 to 4 of 4

Thread: Alternative to Sleep?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    11

    Alternative to Sleep?

    I have a powerpoint presentation that opens via visual basic 6 as shown below. It runs for 236 minutes then closes. Then the program restarts it with updated information that is also in the code, but not included here. My problem is I have a stop command button to stop the timer and stop everything. However, since I used the sleep function below, it freezes the program if I try to access it. Is there an alternative to using the sleep function as shown below? I am used to the newer visual basic so vb6 is outdated for me. Can you provide example and include it in the code below? Thanks...

    Part when it opens powerpoint and runs slide show...

    SPresentationFile = "I:\ISO Documents\QA\SPC Graphs\SPC Presentation.ppt"
    Set oPPTApp = New PowerPoint.Application
    oPPTApp.Visible = True
    Set oPPTPres = oPPTApp.Presentations.Open(SPresentationFile)
    oPPTPres.SlideShowSettings.Run
    Sleep 140000000
    oPPTPres.Close
    oPPTApp.Quit
    Set oPPTApp = Nothing
    Set oPPTPres = Nothing
    End Sub.


    I thought about doing this but it doesn't seem to work... does anyone have any ideas?


    SPresentationFile = "I:\ISO Documents\QA\SPC Graphs\SPC Presentation.ppt"
    Set oPPTApp = New PowerPoint.Application
    oPPTApp.Visible = True
    Set oPPTPres = oPPTApp.Presentations.Open(SPresentationFile)
    oPPTPres.SlideShowSettings.Run
    If Minutes = 236 Then
    oPPTPres.Close
    oPPTApp.Quit
    Set oPPTApp = Nothing
    Set oPPTPres = Nothing
    End If
    End Sub.


    ===
    ===
    ===
    ===
    ===


    Whole code
    Code:
    
    Option Explicit
    
    Private Minutes As Integer
    Dim AccessApp As Object
    
    Dim xlTmp As Excel.Application
    Dim xlBook As Excel.Workbook
    
    Dim oPPTApp As PowerPoint.Application
    Dim oPPTPres As PowerPoint.Presentation
    Dim SPresentationFile As String
    
    Private Declare Sub Sleep Lib "kernel32" _
    (ByVal dwMilliseconds As Long)
    
    Private Sub cmdStart_Click()
    Minutes = 0
    Cls
    Call DoWork
    Timer1.Enabled = True
    End Sub
    
    Private Sub cmdStop_Click()
    Timer1.Enabled = False
    End Sub
    
    Private Sub Form_Load()
    Timer1.interval = 60000
    End Sub
    
    
    Private Sub Timer1_Timer()
    Minutes = Minutes + 1
    If Minutes = 240 Then
    Minutes = 0
    Call DoWork
    End If
    End Sub
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    Private Sub DoWork()
    'Set AccessApp = CreateObject("access.Application")
    'AccessApp.Visible = True
    'AccessApp.OpenCurrentDatabase "I:\Inspectionsystem\Data\DWDATA2.mdb"
    'AccessApp.DoCmd.RunMacro "SPC file updates"
    'AccessApp.CloseCurrentDatabase
    'AccessApp.Quit
    'Set AccessApp = Nothing
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\DD1.XLS")
    'xlTmp.Visible = True
    'xlBook.Close SaveChanges:=True
    'Set xlBook = Nothing
    'xlTmp.Quit
    'Set xlTmp = Nothing
    
    'Sleep 2000
    
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\DD2.XLS")
    'xlTmp.Visible = True
    'xlBook.Close SaveChanges:=True
    'Set xlBook = Nothing
    'xlTmp.Quit
    'Set xlTmp = Nothing
    
    'Sleep 2000
    
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\FP.XLS")
    'xlTmp.Visible = True
    'xlBook.Close SaveChanges:=True
    'Set xlBook = Nothing
    'xlTmp.Quit
    'Set xlTmp = Nothing
    
    'Sleep 2000
    
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\PB-1.XLS")
    'xlTmp.Visible = True
    'xlBook.Close SaveChanges:=True
    'Set xlBook = Nothing
    'xlTmp.Quit
    'Set xlTmp = Nothing
    
    'Sleep 2000
    
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\PB-3.XLS")
    'xlTmp.Visible = True
    'xlBook.Close SaveChanges:=True
    'Set xlBook = Nothing
    'xlTmp.Quit
    'Set xlTmp = Nothing
    
    'Sleep 2000
    
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\SRH-012.XLS")
    'xlTmp.Visible = True
    'xlBook.Close SaveChanges:=True
    'Set xlBook = Nothing
    'xlTmp.Quit
    'Set xlTmp = Nothing
    
    'Sleep 3000
    
    '''''''''''''''''''''''''''''''''''''
    'Set xlTmp = New Excel.Application
    'Set xlBook = xlTmp.Workbooks.Open("I:\ISO Documents\QA\SPC Graphs\spc summary graphs.xls")
    'xlTmp.Visible = True
    'xlTmp.Run ("pastetopowerpoint")
    'xlBook.Close SaveChanges:=True
    'Sleep 5000
    'Set xlBook = Nothing
    'Set xlTmp = Nothing
    
    ''''''''''''''''''''''''''''''''''''''
    Dim intStop As Integer
    SPresentationFile = "c:\zach.ppt"
    Set oPPTApp = New PowerPoint.Application
    oPPTApp.Visible = True
    Set oPPTPres = oPPTApp.Presentations.Open(SPresentationFile)
    oPPTPres.SlideShowSettings.Run
    Sleep 14160000
    oPPTPres.Close
    oPPTApp.Quit
    Set oPPTApp = Nothing
    Set oPPTPres = Nothing
    End Sub
    Last edited by zach campbell; Aug 31st, 2011 at 06:11 PM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Alternative to Sleep?

    Does the oPPTPres object have a method to let you know the presentation is finished? If so, suggest that vs sleeping.

    Can you edit your post and surround your code with appropriate tags. Maybe [code] your code [/code]
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2011
    Posts
    11

    Re: Alternative to Sleep?

    No.

    And sorry, the code is fixed. lol.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Alternative to Sleep?

    You can help us by marking the thread as resolved. If you have JavaScript enabled you can do that by selecting the Mark Thread Resolved item from the Thread Tools menu. Otherwise please insert "[Resolved]" at the start of the Subject and select the green checkmark from the Post Icons.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width