![]() |
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'm trying to write a macro for Outlook 2007, and getting nonsensical compile
errors. For example: The following script results in "Compile error: Object required" Sub TestScript() Dim x As Integer Set x = 2 End Sub Am I doing something wrong or is my Outlook VBA just broken? |
Ads |
#2
|
|||
|
|||
![]()
The "object required" error refers to the "Set" statement, which is only used
for assigning objects. When assigning simple variables, do not use "Set". The correct code is: Sub TestScript() Dim x As Integer ' Set x = 2 results in "Compiler error: Object required" x = 2 End Sub "brookh" wrote: I'm trying to write a macro for Outlook 2007, and getting nonsensical compile errors. For example: The following script results in "Compile error: Object required" Sub TestScript() Dim x As Integer Set x = 2 End Sub Am I doing something wrong or is my Outlook VBA just broken? |
#3
|
|||
|
|||
![]() The Set statement is used only for object variables; but you have declared x as Integer, so x=2 would do it. -- Best regards Michael Bauer - MVP Outlook : Outlook Categories? Category Manager Is Your Tool : VBOffice Reporter for Data Analysis & Reporting : http://www.vboffice.net/product.html?pub=6&lang=en Am Sat, 13 Jun 2009 10:36:01 -0700 schrieb brookh: I'm trying to write a macro for Outlook 2007, and getting nonsensical compile errors. For example: The following script results in "Compile error: Object required" Sub TestScript() Dim x As Integer Set x = 2 End Sub Am I doing something wrong or is my Outlook VBA just broken? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile error | hpoincare | Outlook - Using Forms | 1 | September 9th 08 09:02 PM |
Compile error? | Cam | Outlook and VBA | 5 | April 23rd 08 02:43 PM |
Outlook.MAPIFolder: for each compile error | spareway | Add-ins for Outlook | 1 | January 29th 07 02:05 PM |
Error: Object required "dbe" Line No 25 | Lesley | Outlook - Using Forms | 8 | December 7th 06 12:45 AM |
Script error: Object required | [email protected] | Outlook - Using Forms | 1 | March 17th 06 09:44 PM |