Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Blue Springs, Missouri, USA
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts

    dialogstyle not working

    What worked just fine in 2003 is now causing a problem in 2010. The code reads...

    dialogstyle = vbQuestion + vbYesNo + vbDefaultButton2

    Now gives me the error message of...

    "Compile error:

    Variable not defined."

    What do I need to do now to get this to work?

    DennisK

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Dennis,

    Your 2010 probably has the "Require Variable Declaration" ( Optioin Expicit ) vbe.JPGoption checked in the VBE. Look at the top of your module and you'll see it there.

    Just add: Dim dialogstyle as Integer

    That should get you going. HTH
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  3. #3
    2 Star Lounger
    Join Date
    Sep 2001
    Location
    Blue Springs, Missouri, USA
    Posts
    100
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That was not checked BUT... in planning for the future, I had placed "Option Explicit" in the code. Once I commented that out all seems to work just fine. Thanx SO much for pointing me in the right direction.

    Dennis

  4. #4
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,479
    Thanks
    211
    Thanked 849 Times in 781 Posts
    Dennis,

    Please consider checking that option and always declaring your variables. It makes finding things like incorrectly spelled variables much easier. True it is a little more painful up front to remember to add the declaration each time you need a new variable but in the long run it will be well worth it. As one of my old mentors used to point out "There is never enough time to do things right...but always enough time to fix them later", he said dripping with sarcasm!
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 341 Times in 334 Posts
    I wholeheartedly second RetiredGeek's comments about Option Explicit.

    Steve

Posting Permissions

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