|
-
Oct 31st, 2005, 04:13 PM
#1
Thread Starter
Lively Member
Capture Keydown event from Word document in VB
I actually want to capture the keydown or keypress event from the active word document from my VB6 application.
I know of some events.
Dim WithEvents AppWord As Word.Application
set AppWord = CreateObject("Word.Application")
AppWord.Documents.Add AppMap & "Blanc.doc"
....
Private Sub AppWord_Documentchange()
msgbox "changed to other document"
end sub
There is allso an open and close/quit document event.
but i don't know about a keydown event. Can someone help.
The documenychange would allso be good if this means when the user changes the active document by typing in it, but here it sadly means just switching from one doc to another
If there is no keydown event for this maybe i should try something else
Like capturing the pressed key with a API call like keyboardstate (allready tried this but didn't work because me VB6 form didn't had the focus while typing in de word doc)
Checking a textbox keydown event from the active document would allso be good if possible from my VB. But this seems more difficult. Allso i create the textboxes at run time not at design time
And it's not een array of textboxes (didn't know how to do that). I create textboxes like TKVeld1026 and the next one gets name TKVeld1027 or is there a better way.
Does anyone know a solution, i got stuck here?
-
Nov 1st, 2005, 07:29 AM
#2
Re: Capture Keydown event from Word document in VB
Moved to Office Development.
-
Nov 1st, 2005, 10:14 AM
#3
Re: Capture Keydown event from Word document in VB
There is no DocumentChanged event. Only Open, Close, and New are the relevant events. You may have to, if the doc is saved already, compare the saved content to the current content.
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 
-
Nov 1st, 2005, 11:06 AM
#4
Thread Starter
Lively Member
Re: Capture Keydown event from Word document in VB
Thx for reply
Good to know there is no DocumentChanged event. An other way has to be taken.
You mention checking the saved document with the current,
but i need it to trigger as soon as the user pushes a key! I cannot constantly save the doc.
Allso checking the document in memory, and comparing it a second later for changes, seems strange to do and very slow, and u need a timer...
Maybe i do need to capture a document keydown event somehow, and this through my VB6 application.....
Please some help, i got stuck here
-
Nov 1st, 2005, 12:48 PM
#5
Re: Capture Keydown event from Word document in VB
You may have to do some keyboard hooking involving APIs to get any keypresses. Its not really my area of expertise but could be worth a try or maybe someone has another suggestion
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 
-
Nov 2nd, 2005, 02:28 AM
#6
Thread Starter
Lively Member
Re: Capture Keydown event from Word document in VB
Probably this is the way to go.
I already tried GetKeyboardState api ,
that I put in a timer
But when the focus leaves the form and is in the Word doc, it doesn't catch the keys anymore
I'ts a pity because this normally allso catches mouseclick events and i allso need those !
If there is a more powerfull api, please let me know.
By the way the api should work on all windows systems from Win98 er higher.
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
|