Macro Express News - June 18, 2004:: Whenever the macro file is saved, a copy of the macro file is kept in the need to write a macro that needs to know the location of the My Documents folder? http://www.macros.com/newsletters/MENewsJun2004.htmHOME | I have a macro in my template that I want to copy to several hundred documents. Is there a quicker way to do this than using the macro organizer? I'm using Word 2003. Thanks
This site http://www.cpearson.com/excel/vbe.htm might be helpful. Macro viruses unmasked - Penn Printout, April 1997:: Previously, many viruses were created using lower level system code to infect a document is created using a copy of Microsoft Word that has a macro virus http://www.upenn.edu/computing/printout/archive/v13/8/macro.htmlHOME | Auto-logon Tab - Macro Expert Manual:: An automation tool is designed to complete the repetitive and routine tasks for you, it not only can do whatever you can do, but also it can reduce many operation http://www.macro-expert.com/macro-manual/options-logon.htmHOME |
By changing ThisWorkbook to ActiveDocument this code works for Word.
Sub AddModule()
Dim VBComp As VBComponent
Set VBComp = ActiveDocument.VBProject.VBComponents.Add(vbext_ct _StdModule)
VBComp.Name = "NewModule"
Application.Visible = True
End Sub
Sub AddProcedure()
Dim VBCodeMod As CodeModule
Dim LineNum As Long
Set VBCodeMod = ActiveDocument.VBProject.VBComponents("NewModule").CodeModule
With VBCodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, _
"Sub MyNewProcedure()" & Chr(13) & _
" Msgbox ""Here is the new procedure"" " & Chr(13) & _
"End Sub"
End With
Application.Run "MyNewProcedure"
End Sub
I Am a Sinner – What About You?
Global Sourcing and Supplier Online by Dylan
|