![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
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 |
#5
|
|||
|
|||
![]()
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 |
#6
|
|||
|
|||
![]()
Thanks for your help. I still don't know what was wrong, but I fixed it by
creating a new macro and posting the exact same code into it. Something was clearly messed up with the first macro. "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sub or Function not defined | ladyhawke | Outlook and VBA | 3 | January 27th 07 09:06 PM |
Outlook 2003 error "An internal support function returned an error" with multiple distribution lists | [email protected] | Outlook - Using Contacts | 0 | December 14th 06 10:08 PM |
Import Error with Excel - Too many fields defined | RealGomer | Outlook - Calandaring | 2 | October 27th 06 12:18 AM |
Getting an Internal Support Function Error | TK | Outlook - General Queries | 2 | March 8th 06 01:17 AM |
outlook macro doesn;t run - sub/function not defined | mudshark | Outlook and VBA | 1 | February 6th 06 11:04 PM |