With libraries in the user profile, the following example works:
' FooLibrary.FooModule '
Function FooFn
FooFn = "foo result"
End Function
' in another library i.e Standard.Module1 '
Sub Main
BasicLibraries.LoadLibrary("FooLibrary")
Foo.FooModule.FooFn()
x = Foo.Module
x.FooFn
End Sub
If both of the libraries are embedded in a document instead, or if the Main
Sub is in an embedded library, FooModule.FooFn()
or Foo.FooModule.FooFn()
work, but x.FooFn
throws an error: BASIC runtime error. Object variable not set.
It appears that the reference made available by LoadLibrary()
has different semantics when the calling macro is embedded in a document. When inspecting the references in the IDE, libraries and modules loaded from an embedded macro are always shown as “Out of Scope”, which seems to be related. Is this behavior documented somewhere? Is it a bug?