M
Mo
Hi,
I have posted a problem here earlier regarding code that works in
WindowsXP/Word2007 but not on Windows7/Word2007, but have received no
replies. That problem still exists. I now have another similar problem:
In a global template I store code and global variables. The global template
is in the startup directory so it gets loaded into word at word startup.
Individual templates then make use of that code and variables. This is
accomplished through an autonew macro in each individual template, that at
run-time attaches a reference to that global template. Here is the code
structure:
In the Global template:
Public G_Variable as string
Public Sub AutoExec()
G_Variable = "Hello"
End Sub
Public Sub AddGlobalReference()
ActiveDocument.AttachedTemplate.VBProject.References.AddFromFile Chr(34) &
"TheGlobalTemplateName.dotm" & Chr(34)
ActiveDocument.AttachedTemplate.Saved = True
End Sub
In the Individual templates:
Sub AutoNew()
Application.Run "AddGlobalReference"
MsgBox G_Variable
End Sub
The problem:
When a new document is created with the individual templates and the AutoNew
macro runs
* In Windows7/Word2007 the msgbox displays "" = Not desired result
* In WindowsXP/Word2007 the msgbox displays "Hello" = Desired result
To me a strange thing in Windows7/Word2007 is, that after the AutoNew macro
has finished its execution, if you in VBE, in the Immidiate Window, view the
variable (debug.print G_Variable) it displays "Hello".
Some notes:
* There are no problems with the reference setting - it is set through the
AddGlobalReference code. (If you need a
* First after the execution of the AutoNew is finished, the variable is
usable from the individual templates.
Environment:
* The latest updates are installed via Microsoft Update.
I would be glad if someone, also from Microsoft, could comment on this
problem,
Peeter
I have posted a problem here earlier regarding code that works in
WindowsXP/Word2007 but not on Windows7/Word2007, but have received no
replies. That problem still exists. I now have another similar problem:
In a global template I store code and global variables. The global template
is in the startup directory so it gets loaded into word at word startup.
Individual templates then make use of that code and variables. This is
accomplished through an autonew macro in each individual template, that at
run-time attaches a reference to that global template. Here is the code
structure:
In the Global template:
Public G_Variable as string
Public Sub AutoExec()
G_Variable = "Hello"
End Sub
Public Sub AddGlobalReference()
ActiveDocument.AttachedTemplate.VBProject.References.AddFromFile Chr(34) &
"TheGlobalTemplateName.dotm" & Chr(34)
ActiveDocument.AttachedTemplate.Saved = True
End Sub
In the Individual templates:
Sub AutoNew()
Application.Run "AddGlobalReference"
MsgBox G_Variable
End Sub
The problem:
When a new document is created with the individual templates and the AutoNew
macro runs
* In Windows7/Word2007 the msgbox displays "" = Not desired result
* In WindowsXP/Word2007 the msgbox displays "Hello" = Desired result
To me a strange thing in Windows7/Word2007 is, that after the AutoNew macro
has finished its execution, if you in VBE, in the Immidiate Window, view the
variable (debug.print G_Variable) it displays "Hello".
Some notes:
* There are no problems with the reference setting - it is set through the
AddGlobalReference code. (If you need a
* First after the execution of the AutoNew is finished, the variable is
usable from the individual templates.
Environment:
* The latest updates are installed via Microsoft Update.
I would be glad if someone, also from Microsoft, could comment on this
problem,
Peeter