Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2014, 06:42 PM
pluviosilla pluviosilla is offline Creating Event Handlers Programmatically Windows 7 64bit Creating Event Handlers Programmatically Office 2010 32bit
Novice
Creating Event Handlers Programmatically
 
Join Date: Nov 2014
Posts: 3
pluviosilla is on a distinguished road
Default Creating Event Handlers Programmatically

Lots of stuff on the internet for doing this in Visual Basic & Excel VBA, but so far I haven't found any examples for Word VBA.

I'm looking for a Word VBA substitute for Visual Basic's AddHandler function.
Reply With Quote
  #2  
Old 11-06-2014, 12:05 AM
macropod's Avatar
macropod macropod is offline Creating Event Handlers Programmatically Windows 7 64bit Creating Event Handlers Programmatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Please don't post multiple questions about the same issue (duplicate deleted). For event handling in Word, see, for example:
http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
http://word.mvps.org/FAQs/MacrosVBA/...tSavePrint.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-06-2014, 05:43 AM
pluviosilla pluviosilla is offline Creating Event Handlers Programmatically Windows 7 64bit Creating Event Handlers Programmatically Office 2010 32bit
Novice
Creating Event Handlers Programmatically
 
Join Date: Nov 2014
Posts: 3
pluviosilla is on a distinguished road
Default Not a duplicate

The links you provide do not explain how to programmaticly generate event handlers. Perhaps that can't be done in Word VBA. If not, please tell me. That also would be useful information.

The links you provide duplicate this one:
http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

Great links. Neither address my question.
Reply With Quote
  #4  
Old 11-06-2014, 01:52 PM
macropod's Avatar
macropod macropod is offline Creating Event Handlers Programmatically Windows 7 64bit Creating Event Handlers Programmatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

To programmatically add code to a Word document or template requires the basic process as for Excel, etc.:
1. Set a reference to Microsoft Visual Basic For Applications Extensibility.
2. Give trusted access to the VBE.

The Excel procedure below will add a new module named "NewModule" to ThisWorkbook:
Code:
Sub AddModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub
The Word equivalent is:
Code:
Sub AddModule()
Dim VBComp As VBComponent
Set VBComp = ThisDocument.VBProject.VBComponents.Add(vbext_ct_StdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub
If this isn't the kind of thing you need, you need to say what it is you do need.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-06-2014, 05:36 PM
fumei fumei is offline Creating Event Handlers Programmatically Windows 7 64bit Creating Event Handlers Programmatically Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Word VBA is not as open as Excel VBA regarding events. It would help if you were specific about what you want to accomplish.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Event Handlers Programmatically Adding macro to normal.dotm programmatically etippelt Word VBA 6 04-08-2013 05:55 PM
Programmatically convert Office documents to PDF from C# hemaneelagiri Office 0 10-21-2011 06:07 AM
outlook programmatically read an attachment into byte array chriskaza81 Outlook 0 11-19-2010 01:03 AM
Programmatically get File Path for currently opened WORD document franferns Word 1 11-26-2009 12:36 PM
Programmatically changing folder item selection Richard Cook Outlook 0 02-09-2007 02:25 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:52 AM.


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