No announcement yet.

Macro (not PB MACRO) in another program

  • Filter
  • Time
  • Show
Clear All
new posts

  • Macro (not PB MACRO) in another program

    I have done some searching, but all searches point to #MACRO when what I am asking is something like

    I have a program (lets say Word, or Corel, or OpenOffice) and would like to insert a Macro (in that language) from a particular keystroke

    Only problem is...I did not write the program, so I do not know how it works...and my only answer is "Set the cursor where you want it, and copy-paste"

    Is it possible to insert a macro into a document? that the creating program that makes the document is not my own? (or am I limited to API that the program documents?)

    Something as simple as "Alt-B" (for Billing Address) and "Alt-D" (for Delivery Address") would suffice.

    I hate to ask, and it is probably "Programming 101", but all my searches return PB Macros within your own program, so I had to ask

    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

  • #2
    Hi Cliff,
    I hope I understood correctly what you like to do.

    This is some example code I used to insert a vba-Macro into an Excel-Document via vbs.

    set NCode = objExcel.ActiveWorkbook.VBProject.VBComponents("DieseArbeitsmappe")
     with Ncode.CodeModule
      .InsertLines 1,"sub Seite1Druck()"
      .InsertLines 2,"'druckt die jeweils 1. Seite jeden Tabellenblattes"
      .InsertLines 3,"for i = 1 to sheets.count"
      .InsertLines 4," sheets(i).activate"
      .InsertLines 5," ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1" 
      .InsertLines 6,"next i"
      .InsertLines 7,"end sub"
     end with
     set NCode = Nothing