Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > HOW to Pause and wait for Keystoke

Thread Tools Display Modes
Old 01-18-2005, 03:43 PM
ectoid ectoid is offline
Join Date: Jan 2005
Posts: 8
Default HELP- HOW to Pause until a user Keystoke

Wow, I know the answer is simply but I can't figure it out.
How do I make the excel macro pause and wait for a user keystroke before continuing? The user needs to visually compare a column of data before allowing the macro to continue. I can see how to make the macro wait but not how to pause it indefinately until a user physically presses a specified key.

Last edited by ectoid; 01-18-2005 at 03:55 PM. Reason: clarification
Reply With Quote
Old 01-18-2005, 04:38 PM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
Join Date: Aug 2003
Location: Oregon, USA
Posts: 6,440

Welcome to the forum Ectoid,

VBA is an 'Event' driven program. Not sequencial there is no waiting...

You put the code you want to run under a button event or a keypress event. The code will run when that event fires.

This is pretty fundemental to VB.

For keypresses Your form has a property called 'KeyPreview'. Set it to true at design time. This means that before a keystroke is processed by any control on the form the form keypressed event itself has first crack at it.

Option Explicit Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 'vbShiftMask 1 SHIFT key bit mask. 'VbCtrlMask 2 CTRL key bit mask. 'VbAltMask 4 ALT key bit mask. If Shift = vbAltMask Then 'Alt key pressed. If KeyCode = Asc("A") Then 'Run your code here. End If End If End Sub

Burn the land and boil the sea
You can't take the sky from me

Reply With Quote
Old 01-18-2005, 04:58 PM
ectoid ectoid is offline
Join Date: Jan 2005
Posts: 8

Hey, thanks Gruff...
I think I figured it out...sweet!!
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..