![]() |
#1
|
|||
|
|||
![]() 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. |
#2
|
||||
|
||||
![]()
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] |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
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 Code:
Sub AddModule() Dim VBComp As VBComponent Set VBComp = ThisDocument.VBProject.VBComponents.Add(vbext_ct_StdModule) VBComp.Name = "NewModule" Application.Visible = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
Word VBA is not as open as Excel VBA regarding events. It would help if you were specific about what you want to accomplish.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
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 |