Jump to content

Nested With Statements


Recommended Posts

I tried using some code like this earlier and was surprised to see it fail:

With .Sheet(1)
    ; ...
    With .Range($myRange)
    ; ^-- "C:\test.au3" (105) : ==> Object referenced outside a "With" statement.:
        .Interior.ColorIndex = 44
        .Borders.ColorIndex = 0
    EndWith
EndWith

It doesn't allow me to use the previous reference to ".Sheet(1)" inside the second With statement. Is this a bug or this intended? (Coming from VBA, it looks like a bug :))

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

18 minutes ago, seadoggie01 said:

Is this a bug or this intended?

I assume it's deliberate, see : https://www.autoitscript.com/autoit3/docs/appendix/Exitcodes.htm

0x7FFFF0A8 : Nested "With" statements are not allowed.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...