![]() |
|
#4
|
||||
|
||||
|
To transfer the code and detach the template, you could use a macro like:
Code:
Sub CopyCodeModule() Dim StrModule As String StrModule = "MyModule" ' Delete any old copies of the module On Error Resume Next Kill (StrModule & ".bas") On Error GoTo 0 ' Export Module ActiveDocument.AttachedTemplate.VBProject.VBComponents(StrModule).Export (StrModule & ".bas") ' Import Module Application.VBE.ActiveVBProject.VBComponents.Import (StrModule & ".bas") ' Delete the module copy Kill (StrModule & ".bas") ActiveDocument.AttachedTemplate.Name = "" End Sub Note: To use the above code, you need to set a reference to Microsoft Visual Basic For Applications Extensibility and grant access to VBA object model (see http://support.microsoft.com/kb/282830)
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| macro problem |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I save a Word file with a macro for distribution? | leemoreau | Word VBA | 3 | 10-04-2013 08:06 AM |
Comparing with a model format
|
qetuo | Word | 2 | 05-01-2013 11:23 PM |
Macro to create new word doc and save the file using String found in the document
|
VBNation | Word VBA | 2 | 02-08-2013 07:14 AM |
| Word ask to save template whenever i save a derived document | jorbjo | Word | 3 | 10-04-2012 10:52 AM |
NEED macro to save word doc as pdf
|
socrates01 | Word | 3 | 07-11-2011 05:12 AM |