Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Apr 2009
    Location
    Melbourne, Australia
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Compile error since Windows patches

    I have a set of Word macros that were working last week, but since I applied the recent Windows patches, I get a compile error - "Constant expression required" in a loop where I am using something I have declared as a CONST. This template/macro has been working for more than 6 months, and I was adding some features last week, but I did not change the way I declared my constants - updates were in a different part of the macro but the error shows up in a part I've not altered. The version in production still works OK.

    I am on Windows 7 with MS_Word 2010.

    Anyone else have problems since the recent patches?

    For reference - my CONST declarations:

    ' in the control file
    Const cCFileType As String = "FileType"
    Const cCRecordCount As String = "RecordCount"
    Const cCRemitAmount As String = "TotalRemitAmount"
    Const cCRemitCount As String = "TotalRemitCount"
    Const cCRemitDate As String = "RemitDate"


    and the first place I use them:
    Code:
        For j = 0 To i
            Select Case arrControl(j)
                Case cCFileType
                    idxCFileType = j
                Case cCRecordCount
                    idxCRecordCount = j
                Case cCRemitAmount
                    idxCRemitAmount = j
                Case cCRemitCount
                    idxCRemitCount = j
                Case cCRemitDate
                    idxCRemitDate = j
                Case Else
                    ' nothing else to set
            End Select
        Next j
    Last edited by RetiredGeek; 2013-10-21 at 05:56. Reason: Added code tags.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,509
    Thanks
    3
    Thanked 143 Times in 136 Posts
    How is arrControl() defined? Is it a string array?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #3
    New Lounger
    Join Date
    Apr 2009
    Location
    Melbourne, Australia
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes - defined as Dim arrControl() as String

    and it gets ReDim'ed when it is populated from a text file.

  5. #4
    New Lounger
    Join Date
    Apr 2009
    Location
    Melbourne, Australia
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Problem solved (or at least removed).

    I now suspect I had some sort of corruption.
    I went back to an earlier backup and added in my changes a step at a time and all works well - there is no "Constant expression" error anymore.

Posting Permissions

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