![]() |
#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] |
Thread Tools | |
Display Modes | |
|
![]() |
||||
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 |