Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-28-2024, 07:18 AM
ctviggen ctviggen is offline Addressing timing issues (doing things too fast causes a problem) Windows 10 Addressing timing issues (doing things too fast causes a problem) Office 2016
Advanced Beginner
Addressing timing issues (doing things too fast causes a problem)
 
Join Date: Feb 2021
Posts: 54
ctviggen is on a distinguished road
Default Addressing timing issues (doing things too fast causes a problem)

I have some timing issues in different subroutines.




Timing issue #1. This subroutine (1) adds text, pastes copied text, manipulates the pasted text; (2) performs (1) with different added text and manipulation; (3) performs (1) with different added text and manipulation... When I tested this manually by stepping through the code, it worked fine. When I ran it normally, it threw errors. So, before I pasted the copied text, I added a subroutine that did nothing but delay for a second. I run the delay right before every instance of pasting text. This corrects the error but creates a "choppy" UI, as this is seen by a user: something happens; it stops; something happens; it stops; etc.



Timing issue #2. For this subroutine, I copy text from a currently open document, set an insertion point in that document, open a new document, paste the copied text there, then immediately begin manipulating hidden bookmarks and their corresponding cross-references. After other manipulation, the manipulated text gets copied back to the insertion point in the currently open document and the new document gets closed. I tested this on different computers with the same Word file, and sometimes the manipulation of bookmarks/cross-references works, and sometimes it doesn't. Again, I think there's a timing issue. I think adding a delay before beginning the manipulation of bookmarks/cross-references would work. However, this would make this code run longer (the user does not see the manipulation here, though).



This is the code I'm using for a delay (not my code, someone else created it):


Code:
Private Sub TIMERUN(SEC As Single)
    PauseTime = SEC ' Set duration.
    Start = Timer ' Set start time.
    Do While Timer < Start + PauseTime
        DoEvents ' Yield to other processes.
    Loop
End Sub
But is there a better way to address these timing issues other than adding a simple delay?



Thank you.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Addressing timing issues (doing things too fast causes a problem) creating a named row for dynamic addressing trevorc Excel Programming 8 07-08-2018 03:21 AM
Need help fast! taavidude Outlook 1 07-30-2014 01:03 AM
Addressing timing issues (doing things too fast causes a problem) Addressing families of different sizes ryanjanus Mail Merge 2 12-17-2012 07:05 PM
Addressing mailing envelopes WildBill Outlook 0 12-29-2011 03:20 PM
Outlook 2000 addressing problem speigel Outlook 0 11-08-2006 02:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft