I am not sure how that would work.
In it's most simple form this is how the situation is:

In Add-in:

Public VarABC as String

Sub RunImportedSub()
Application.Run strImportedSub
End Sub

In text file:

Sub strImportedSub()
VarABZ = "test"
End Sub

Then VarABZ is nowhere declared in the add-in and the compile error occurs.
I can't alter the text files as they are with different people in different
places.
All I can do is alter the add-in to deal with this.


RBS



"Dave Peterson" <ec35720@netscapeXSPAM.com> wrote in message
news:4274C20B.439BA9EB@netscapeXSPAM.com...
> If they're public variables, maybe you could put them in the same module
> so that
> their declaratations get imported, too.
>
> But I think I would try to rewrite the sub so that any variables that it
> needs
> are passed as parameters.
>
> Then I could just pass the parms I need in the line that calls the sub.
>
> RB Smissaert wrote:
>>
>> Do I conclude then that there is just no solution for this?
>>
>> RBS
>>
>> "RB Smissaert" <bartsmissaert@blueyonder.co.uk> wrote in message
>> news:OlThA0$SFHA.2872@TK2MSFTNGP14.phx.gbl...
>> > Have the following situation:
>> > An .xla file will import a Sub from a text file and then run it like
>> > this:
>> >
>> > Dim strSub as String
>> >
>> > 'some code here to get the Sub imported
>> > Application.Run strSub
>> >
>> > Now it is possible that in this imported Sub are variables that are
>> > not
>> > defined publicly, so there
>> > will be a compile error, variable not defined.
>> > As this is not a runtime error I am not sure this error can be handled
>> > gracefully, but I would be interested
>> > in any suggestions how this could be done.
>> >
>> >
>> > RBS
>> >

>
> --
>
> Dave Peterson