Ok, sorry for the bad post before,
The way I know I am in the IDE is with #Constants

in your declarations section type
#Const InIDE = 1 'Change to 0 for when you don't want to execute code based on this value

Then anywhere you want to test it you would type
VB Code:
  1. #If InIDE Then
  2.     'put code for what you want to do if you are in the ide here
  3. #Else
  4.     'put code for what you want to do other wise here
  5. #End If

This works, I took the time to test it before I posted.