G
Gunther Maier
Hi,
I am trying to imitate the way Endnotes stores citations in word
documents. This is done via an ADDIN field. This field shows, for
example, author and year in the regular display of Word, and a long XML
string when the filed codes are displayed. According to ma checking, the
author and year information is stored in .Result.Text in the field, the
XML string in .Code.Text.
I can read Code.Text and Result.Text from an existing ADDIN field as
with the following macro:
Sub Makro3()
Dim f As Word.Field
Set f = ActiveDocument.Range.Fields.Item(1)
MsgBox (f.Result.Text)
MsgBox (f.Code.Text)
f.Result.Text = "BLA, BLA, BLA"
End Sub
This macro ALSO replaces the original .Result.Text by my new text "BLA,
BLA, BLA". This is also reflected in Word in the expected way.
NOW COMES THE PROBLEM:
While everything works fine with existing ADDIN fliends, when I create
my own ADDIN field, I CANNOT store anything in .Result.Text, as in the
following macro (the length of the Text should not bother you, I tried
different things there):
Sub Makro2()
Dim f As Word.Field
Set f = Selection.Fields.Add(Range:=Selection.Range,
Type:=wdFieldAddin, Text:= _
"EN.CITE
<EndNote><Cite><Author>Lefebvre</Author><Year>1991</Year><RecNum>961</RecNum><record><rec-number>961</rec-number><ref-type
name=""Book"">6</ref-type><contributors><authors><author>Lefebvre,
H.</author></authors></contributors></Cite></EndNote>",
PreserveFormatting:=False)
f.Result.Text = "BLA, BLA, BLA"
End Sub
Word does not complain or produce any error message when I run this
macro. However, the line 'f.Result.Text = "BLA, BLA, BLA"' does not
alter the .Result.Text of the field as in the previous macro. It is
still equal to Nothing as before. The text is actually written after the
ADDIN field into the document.
Does anyone have an idea what causes this problem?
Kind regards
Gunther Maier
I am trying to imitate the way Endnotes stores citations in word
documents. This is done via an ADDIN field. This field shows, for
example, author and year in the regular display of Word, and a long XML
string when the filed codes are displayed. According to ma checking, the
author and year information is stored in .Result.Text in the field, the
XML string in .Code.Text.
I can read Code.Text and Result.Text from an existing ADDIN field as
with the following macro:
Sub Makro3()
Dim f As Word.Field
Set f = ActiveDocument.Range.Fields.Item(1)
MsgBox (f.Result.Text)
MsgBox (f.Code.Text)
f.Result.Text = "BLA, BLA, BLA"
End Sub
This macro ALSO replaces the original .Result.Text by my new text "BLA,
BLA, BLA". This is also reflected in Word in the expected way.
NOW COMES THE PROBLEM:
While everything works fine with existing ADDIN fliends, when I create
my own ADDIN field, I CANNOT store anything in .Result.Text, as in the
following macro (the length of the Text should not bother you, I tried
different things there):
Sub Makro2()
Dim f As Word.Field
Set f = Selection.Fields.Add(Range:=Selection.Range,
Type:=wdFieldAddin, Text:= _
"EN.CITE
<EndNote><Cite><Author>Lefebvre</Author><Year>1991</Year><RecNum>961</RecNum><record><rec-number>961</rec-number><ref-type
name=""Book"">6</ref-type><contributors><authors><author>Lefebvre,
H.</author></authors></contributors></Cite></EndNote>",
PreserveFormatting:=False)
f.Result.Text = "BLA, BLA, BLA"
End Sub
Word does not complain or produce any error message when I run this
macro. However, the line 'f.Result.Text = "BLA, BLA, BLA"' does not
alter the .Result.Text of the field as in the previous macro. It is
still equal to Nothing as before. The text is actually written after the
ADDIN field into the document.
Does anyone have an idea what causes this problem?
Kind regards
Gunther Maier