I have a Word document with some functions. I want to access these functions in formula fields, but this was harder than anticipated.
Let's say I have a function defined as
Public Function Area(R As Double) As Double
Area = 3.14 * R * R
End Function
and that I want to use this in a field, like this
{ = Area(RadiusBookmark) }
This seems pretty straight forward, but I get a syntax error. If I omit the parameter, like this
{ = Area }
I get an "undefined bookmark" error, which leads me to believe that only bookmarks are available to the formula code fields.
.Variables("somename").Value = "somevalue"
will implicitly invoke the.Add
method if you're inputting a variable name that hasn't been created yet. SoSub setvar()
in this example would be functionally equivalent if it were simply written as:ThisDocument.Variables("MyFuncResult").Value = Foo
:
ThisDocument.Fields.Update
– Paramedic