Boris
January 26th, 2000, 01:50 AM
Hi!
I work with VB 6.0
Is it possible to create a Word Makro from another, or to change or alter a Makro. If yes, how will i do this?
Thank you!
Bye.
Lothar Haensler
January 26th, 2000, 03:48 AM
in Word2000 you can get the text of a macro via the Word and VBIDE object model:
Step 1: open the document
Dim w as new Word.Application
Dim d as Word.Document
set d = w.Documents.Open("c:\test2.doc")
w.Visible = true
2. now access the VBProject sub object of the document object.
e.g. get the source text for macro "test"
' get the start line number
d.VBProject.VBComponents("Newmacros").CodeModule.ProcStartLine("test",vbext_pk_Proc )
' get the number of lines in the proc
d.VBProject.VBComponents("Newmacros").CodeModule.ProcCountLines("test",vbext_pk_Proc )
' get the source text of the macro
d.VBProject.VBComponents("Newmacros").CodeModule.Lines(1,7) ' returns a string which contains the source text.
you need to add a reference to the Word Type library and VBIDE type lib.
To add a new macro, use the Add method of the VBComponents sub object of the VB Project object