Ok Kirm...

This has become a bit of a vandetta on my part... you've probably got some work-around by now and if you do - cudo's. But now it's just gotten personal. We Canadians can be persistent bastards, can't we ?

This script will do two things...

1) Enumerate all the VB CodeModules (macros) in Normal.dot

2) Add a VB macro module into normal.dot if it doesn't already exist.

One can manually see and verify all the module names and sourcecode using the following winword menu item ...

tools->macro->macros...->organizer

Always use the organizer when managing macro modules (adding,deleting).

Here's the macro module. Change the script variable $module_file to point to the module.

[file: kixtart.bas]

code:

Attribute VB_Name = "KiXtart"
Sub KixRox()
Attribute KIXTART.VB_Description = "Macro recorded 10/08/99 by Shawn"
Attribute KIXTART.VB_ProcData.VB_Invoke_Func = "Normal.KiXtart.KixRox"


'
' KIXTART Macro
' Macro recorded 10/08/99 by Shawn
'

Selection.TypeText Text:="KiXtart 2001 Rox !"


End Sub


and the script...

code:

break on cls


$module_name = "kixtart" ; <--- module name ?
$module_file = "m:\macro\kixtart.bas" ; <--- and the filename ?


$vb_ext_ct_classmodule = "1"


$word = olecreateobject("word.application")


if $word


$template = val("&"+olegetproperty($word,"NormalTemplate"))


if $template


$document = val("&"+olecallfunc($template,"openasdocument"))


if $document


$vbproject = val("&"+olegetproperty($document,"vbproject"))


if $vbproject


$vbcomponents = val("&"+olegetproperty($vbproject,"vbcomponents"))


if $vbcomponents

$index = 1
$component = val("&"+olecallfunc($vbcomponents,"item","i","$index"))


while @error = 0


$name = olegetproperty($component,"name")
$type = olegetproperty($component,"type")


if $name = "$module_name" and $type = "$vb_ext_ct_classmodule"
$classmodule = $component
else
$= olereleaseobject($component)
endif
$index = $index + 1
$component = val("&"+olecallfunc($vbcomponents,"item","i","$index"))
loop


$= olereleaseobject($component)


if $classmodule
?"$module_name module already loaded!"
$= olereleaseobject($classmodule)
else
?"Loading $module_name module ... "
$new= val("&"+olecallfunc($vbcomponents,"import","s","$module_file")) "@serror"
$= olereleaseobject($new)
endif


$= olereleaseobject($vbcomponents)


endif


$= olereleaseobject($vbproject)


endif

$= olereleaseobject($document)


endif

$= olereleaseobject($template)

endif


; ?"pause..." gets $k


$= olecallfunc($word,"quit")


$= olereleaseobject($word)


endif


exit


Shawn.

[This message has been edited by Shawn (edited 04 April 2001).]