Re: Accessing a PRIVATE field within a MACROBUTTON

From: sprungli (sprungli1_at_netscape.net)
Date: 07/22/04


Date: Thu, 22 Jul 2004 17:23:19 -0400

Thanks Howard,

I had already tried this, but it doesn't work. If you just replace it that
way, the MACROBUTTON diappears from the document. The code is replaced by
its value, although only some text of the field is changed, not the field
itself.

Is there another way of getting to the PRIVATE field inside a MACROBUTTON?

"Howard Kaikow" <kaikow@standards.com> wrote in message
news:O%23$5s41bEHA.1356@TK2MSFTNGP09.phx.gbl...
> You don't want to unlink the fields.
>
> Just parse the content of the Macrobutton field to find the Private field
> and replace the content of the Private field, not the field itself.
>
> --
> http://www.standards.com/; See Howard Kaikow's web site.
> "sprungli" <sprungli1@netscape.net> wrote in message
> news:eFTJHxzbEHA.1048@tk2msftngp13.phx.gbl...
> > Hello,
> >
> >
> >
> > My project uses macrobuttons to display and process portions of text
> within
> > a document. Each MACROBUTTON contains a PRIVATE field, whose value
(text)
> is
> > used by the macro called upon clicking the MACROBUTTON. For example, if
> >
> >
> >
> > { MACROBUTTON Some text to find } is the MACROBUTTON,
> >
> >
> >
> > then the value of its code would be
> >
> >
> >
> > "  PRIVATE Some text to find MACROBUTTON MacroBtnClicked Some text to
> find
> > "
> >
> >
> >
> > where MacroBtnClicked is the name of the macro to call.
> >
> >
> >
> > When the user clicks the MACROBUTTON, the MacroBtnClicked performs some
> > processing with the value of the PRIVATE field. At some point I need to
> find
> > the text contained within a MACROBUTTON, present the user with the
> > possibility to edit this text (this happens in a dialog), then save the
> > changes back to the MACROBUTTON. One possible solution is to find the
> > MACROBUTTON displaying the text in question, unlink it, then recreate it
> > with the changed text for both the MACROBUTTON itself and the inner
> PRIVATE
> > field, as well. I have been wondering though whether there was a more
> > elegant (and lasier) way of achieving this. I can change the text of the
> > MACROBUTTON with something like:
> >
> >
> >
> > Dim txtToFind As String
> >
> >
> >
> > txtToFind = "Some text to find"
> >
> >
> >
> > 'switch codes On
> >
> > ActiveDocument.Fields.ToggleShowCodes
> >
> >
> >
> > With Selection.Find
> >
> > .ClearFormatting
> >
> > .Forward = True
> >
> > .Wrap = wdFindStop Or wdFindContinue
> >
> > .Text = txtToFind
> >
> > .Execute
> >
> >
> >
> > The line above selects the searched text; it can be easily replaced and,
> > with Codes Off, the MACROBUTTON displays the new text. The problem is
the
> > PRIVATE field: I can't access it, to change its text too. See the code
> > below. The value of aField is Empty and the Selection.Fields collection
is
> > of length 0.
> >
> >
> >
> > 'switch codes Off
> >
> > ActiveDocument.Fields.ToggleShowCodes
> >
> >
> >
> > privateFieldTxt = "  PRIVATE " + txtToFind
> >
> >
> >
> > Do While Selection.Find.Found
> >
> > For Each aField In Selection.Fields
> >
> > If StrComp(aField.Code.Text,
> > privateFieldTxt, 1) = 0 Then
> >
> > 'set the
aField.Code.Text
> to
> > the new text here.
> >
> > End If
> >
> > Next aField
> >
> > Loop
> >
> > End With
> >
> >
> >
> > Am I on the right track? I am almost sure this can be done; but how to
get
> > to the PRIVATE field?
> >
> >
> >
> > Thanks in advance for any possible solutions.
> >
> >
>
>