|
-
Oct 10th, 2005, 10:24 AM
#1
Thread Starter
Fanatic Member
[RESOLVED]Stopping Execution
Is it possible to stop or step into the code of a macro as it is loading when you start word? In other words, when I start word the macro starts normally, but is it possible to step into the code as it begins to execute for the first time. So as soon as word starts I want it to start executing the macro but I also want to able to step through the code and debug it.
Thanks.
Last edited by Jumpercables; Oct 12th, 2005 at 11:16 AM.
-
Oct 10th, 2005, 10:29 AM
#2
Re: Stopping Execution

VB Code:
'Some of your macro code.
'
'
Stop
'More macro code.
'
'
Press F8 to contine debugging after the Stop code.
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 
-
Oct 10th, 2005, 10:47 AM
#3
Thread Starter
Fanatic Member
Re: Stopping Execution
Fantastic - Also under want reference name in VBA is the timer control?
-
Oct 10th, 2005, 10:54 AM
#4
Re: Stopping Execution
Its not a control but rather a function call - Timer
From the help file...
VB Code:
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If
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 
-
Oct 10th, 2005, 10:58 AM
#5
Re: Stopping Execution
You can also use the Sleep API to pause execution..
VB Code:
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Sub temp()
'code
Sleep 1000 'pause for one second
'more code
End Sub
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Oct 10th, 2005, 11:05 AM
#6
Re: Stopping Execution
Yes, but then your not immediatly thrown into debug mode and if you dont press Ctl+Break soon enough it will continue on processing.
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 
-
Oct 10th, 2005, 11:13 AM
#7
Thread Starter
Fanatic Member
Re: Stopping Execution
Hmm, Im not sure why this is so hard but I just want to have my form that states "Loading Blah Settings" show at the start of execution for 5 seconds then close. But it doesnt seem to pass off control once the form is loaded until I close the form.
-
Oct 10th, 2005, 11:40 AM
#8
Re: Stopping Execution
RD,
Your method takes two Message boxes which requires user intervention, if the programmer wants to pause execution for 5 seconds why would they want it to go into break mode straight after?
Danny
Never Think Impossible
If you find my answer helpful then please add to my reputation
-
Oct 10th, 2005, 11:44 AM
#9
Re: Stopping Execution
Your original question was how to stop code execution and enter into debug mode. Why dont you let us know what your really trying to do?
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 
-
Oct 10th, 2005, 11:46 AM
#10
Re: Stopping Execution
 Originally Posted by dannymking
RD,
Your method takes two Message boxes which requires user intervention, if the programmer wants to pause execution for 5 seconds why would they want it to go into break mode straight after?
What are you talking about? He asked for stopping code to start debuging and then how to use a timer. Now hes changed things it will depend upon what he wants to do.
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 
-
Oct 10th, 2005, 04:34 PM
#11
Thread Starter
Fanatic Member
Re: Stopping Execution
Rob you answered my question prefectly. My other question about the timer is completely unrelated to the first one regarding the stop execution
My question about the timer was regarding something different that just came to mind while I was writing about the stop execution and figured since you moderators know everything about vb or vba I would kill two birds with one stone.
I wanted a timer to run to display a form saying "Loading Configuration Settings" then after about 5 seconds it would automatically close then continue with the rest of the code.
-
Oct 10th, 2005, 04:42 PM
#12
Re: Stopping Execution
You can use either a loop with a timer or the sleep api. Both will work.
VB Code:
Dim iStop As Long
lStop = Timer + 5
frmSplash.Show
Do While Timer <= lStop
DoEvents
Loop
UserForm1.Show
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
|