Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Redditch, Worcestershire, England
    Posts
    233
    Thanks
    0
    Thanked 22 Times in 21 Posts

    AddressOf won't compile

    The following line of code:

    lRet = EnumWindows(AddressOf EnumWindowProc,lParam)

    refuses to compile within the VBE in Excel 97. The cursor highlights AddressOf and the error message is Compile error: Expected: expression.

    Subsequent attempts to compile result in Syntax error as the error.

    lRet and lParam are declared as Long and EnumWindowProc is a public function in a module within Excel.

    All API declarations have been checked against various sources.

    Anyone seen this before?

    Jeremy

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AddressOf won't compile

    Looks like you've got a [space] after the Of

    I pasted this from your post:
    AddressOf EnumWindowProc

    That's a [space] alright.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Redditch, Worcestershire, England
    Posts
    233
    Thanks
    0
    Thanked 22 Times in 21 Posts

    Re: AddressOf won't compile

    The space is deliberate. AddressOf is an operator used to pass the address of a function to a procedure.

    It seems to be a version problem - the code is OK in Excel 2000 but fails in 97 (which I have at work). I just can't find any documentation that indicates that the behaviour changed between releases.

    Jeremy

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: AddressOf won't compile

    Shows you what I know. But, I believe Office 97 does not support any of the Enum fucntions. I'm fairly certain of that.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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