RE: sub or function not defined error - HELP!!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Forgive my ignorance of Outlook VB Macros - this is very frustrating.

The error occurs before my form loads. I have more code, but it is all on
the controls on userform1, which doesn't even load when I go through the menu
tree Tools->Macro->Macros->SpamDeath->Run. As soon as I click on Run, I get
the sub or function not defined messagebox. I did what you suggested and put
on error statements in absolutely every subroutine in my project, and those
errors never get triggered. This appears to be something in the initial
running of the Macro before it executes. My form never loads, just the
messagebox...


"Eric Legault [MVP - Outlook]" wrote:

At what line does the error occur? Is that ALL your code?? Also try
inserting On Error Goto <YourLabelNumber> statements in all your methods so
that you can properly determine where the error is occuring during runtime.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"adenke" wrote:

I did that. I assume that Option Explicit goes in the Declarations section of
the module. The behavior is exactly the same. When I try to compile the code,
it doesn't seem like anything happens (other that "Complile Spamdeath" (my
project name) turns grey after running "Compile Spamdeath once). No errors
pop up or anything. If I add the statement "bob=mickeymouse(), then it shows
me that mickeymouse() doesn't exist, so I'm guessing that the sub or function
not defined error is a red herring for the actual problem.

All I have in my project is this:

Option Explicit

Public Sub SpamDeath()

UserForm1.Show
End Sub

Plus a user form with some ListBoxes and CommandButtons and the code
associated with those.

I am throroughly confused here. I do a lot of VB programming, but this is my
first macro through MSOffice attempt since a much earlier version of Excel.

It may be worth noting that I went into the VB Editor first to create the
project and then later did the "Create" step from the macro directory at
which point I added the line of code to load my form. Perhaps that was wrong?

"Eric Legault [MVP - Outlook]" wrote:

Turn on Option Explicit and try compiling your code - it'll tell you where
there are calls for functions or procedures that don't exist.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"adenke" wrote:

I have created a Macro in VB in Outlook 2007, and when I run it, I get a "Sub
or function not defined" error message box. I have not been able to
troubleshoot this properly. Once I click OK on the message box, I can just
press F5 and the macro runs perfectly, but I would rather not have this
annoying step. Where should I look for the problem
.



Relevant Pages

  • Re: This macro to auto-fill all e-mail fields worked in 2003; not
    ... Dim myOlApp As New Outlook.Application ... "Sub or Function not defined" is the error coming up. ... Author of Microsoft Outlook 2007 Programming: ... Is there something I cann add to this macro to have it work in Outlook 2007? ...
    (microsoft.public.outlook.program_vba)
  • Re: Button to automate new message settings
    ... Here's a macro to automate inserting a signature by name into the active e-mail: ... Sub InsertSpecificSignature ... Dim objSigButton As Office.CommandBarButton ... Full documentation on the object model is available from the Help menu in the Outlook VBA IDE, ...
    (microsoft.public.outlook.program_vba)
  • Re: Email and if statements
    ... > I am a BIG novice to programming in VB and I need help creating a macro ... The macros below use Outlook. ... Your major adaptation will probably be in defining the CustomerInfo ... 'Interface with Outlook objects required will be through this sub. ...
    (microsoft.public.excel.programming)
  • Re: Write macro to attach PDF files in a folder as attachments to
    ... If the code is exiting at the "If ActiveInspector Is Nothing Then Exit Sub" ... Eric Legault - B.A, MCP, MCSD, Outlook MVP ... The macro doesn't work still. ... HOWEVER, it can't attach attachments. ...
    (microsoft.public.outlook.program_vba)
  • Re: a newbie writes .... kicking off ItemAdd event
    ... "myOlApp" can be deleted, use the intrinsic Application object instead. ... Private Sub Application_Startup ... Michael Bauer - MVP Outlook ... > in another module or macro to get it to work. ...
    (microsoft.public.office.developer.outlook.vba)