Results 1 to 2 of 2
  1. #1
    Star Lounger
    Join Date
    Feb 2001
    Auckland, North Island, New Zealand
    Thanked 0 Times in 0 Posts

    Manage missing routines in VBA (2003)

    Is there any way of tricking a VBA sub-routine into running a module if it is present but, if it isn't present, not causing an error message?

    I am working on a module which is to be distributed alone. It requires some things done in the AutoExec() file. However my normal working environment also requires some things done in AutoExec.

    In my working environment I can put the AutoExec into the takeaway module like:

    Sub AutoExec()
    'do some things required by the takeaway module
    msgbox "This is in the takeaway autexec"

    'now do the local stuff
    End Sub

    In my "stay at home" module I have put the things which used to be in the AutoExec into another module

    Sub LocalAutoExec()
    'do some things required locally
    msgbox "This is in a local 'stay at home' routine"
    End Sub

    THe problem is that I get a compile error when I have created the distribution version which doesn't contain the module with LocalAutoExec() in it. I don't want users to get this message of course.

    I hope I've made this clear enough. I suspect there isn't an answer because VBA can't be compiled conditionally.

    But maybe there's a solution... I'd be very grateful to learn of it. Thank you.

    Jim BRook.

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Thanked 7 Times in 7 Posts

    Re: Manage missing routines in VBA (2003)

    > VBA can't be compiled conditionally

    VBA will only compile a module if at least one thing in that module is executed. So you should be able to use separate modules for each environment and simply define a flag (or maybe even an environment variable outside of Word) to tell VBA whether to call things.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts