+ Reply to Thread
Results 1 to 10 of 10

Delay then continue

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Delay then continue

    I have a form that has 20 text boxes that are populated from a spreadsheet. The text boxes are populated with names of .pdf files. What I'm trying to do is print the contents of the text boxes. There needs to be a 5 second delay between each print. What I tried to do is use the application.wait to pause for 5 seconds and then loop through until each text box has been printed. After I have printer the contents of a text box I'm changing the back colour to green. The problem I have is when I try to print the first box goes green and then when all are complete the others go green. I can't get it to go green after every 5 second delay.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Delay then continue

    In End stage reset all the check box color to default by way of looping


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    05-18-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Delay then continue

    It's the text boxes that I want to change the colour of. I've run the code on its own using a loop and it works. Every five seconds the text boxes change colour. When I run the same code with the code to print the files it won't change the colour it waits until all are printed and changes them all at once

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Delay then continue

    Whether your code turning OFF the screen updating?

  5. #5
    Registered User
    Join Date
    05-18-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Delay then continue

    Tried that I removed all application.screenupdating and still doesn't work. I'm wondering if it's cause I'm printing that it's not doing it

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Delay then continue

    If possible, please share the code with us

  7. #7
    Registered User
    Join Date
    05-18-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Delay then continue

    The code im using to loop is as follows sorry trying to do this from my phone and not sure how to add code.
    Do Until num = itemNum
           num1 = InStr(1, UCase(Me.Controls("TextBox" & num).Text), ".PDF")
           If num1 <> 0 Then
               flag = 1               
               strDir = folder
               strFile = Me.Controls("TextBox" & num).Text
                    If Me.Controls("chBox" & num).Value = True Then
                        printThis = PrintThisDoc(0, strDir & "\" & strFile)
                        Application.Wait (Now + TimeValue("0:00:05"))
                        Me.Controls("TextBox" & num).BackColor = VBGreen
                    Else
                        Me.Controls("TextBox" & num).BackColor = VBRed
                    End if
           End If
    num = num + 1
    loop
    within a module I have this code to print

    Public Function PrintThisDoc(forname As Long, FileName As String)
    On Error Resume Next
    Dim X As Long
    X = ShellExecute(forname, "Print", FileName, 0&, 0&, 3)
    End Function
    As I said all TextBoxes change colour after the code has completed not after every 5 second delay.
    Last edited by vlady; 02-15-2015 at 10:17 PM.

  8. #8
    Registered User
    Join Date
    05-18-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Delay then continue

    Anyone have any ideas why?

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,024

    Re: Delay then continue

    Does it help if you add:
    DoEvents
    Me.Repaint
    after the line that changes the textbox colour?
    Everyone who confuses correlation and causation ends up dead.

  10. #10
    Registered User
    Join Date
    05-18-2010
    Location
    Luton, England
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Delay then continue

    Excellent thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Hyperlink delay
    By Tortus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2014, 04:41 PM
  2. [SOLVED] Delay the workbook?
    By mdovey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2013, 03:01 AM
  3. Delay when deleting row
    By Marcelo Rychter in forum Excel General
    Replies: 4
    Last Post: 01-06-2013, 02:45 PM
  4. Delay Macro
    By Jazzy Max in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-11-2010, 09:27 PM
  5. Delay
    By shapper in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2008, 08:41 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1