CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Word Makro

  1. #1
    Join Date
    Jan 2000
    Posts
    5

    Word Makro

    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.


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Word Makro

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured