Consulting

Results 1 to 2 of 2

Thread: Word controlling Excel using UsedRange.Rows no longer works in Windows 11

  1. #1
    VBAX Regular
    Joined
    Mar 2018
    Location
    Leesburg
    Posts
    71
    Location

    Word controlling Excel using UsedRange.Rows no longer works in Windows 11

    Hello, all of the sudden, once I updated to Windows 11 on both my 32-bit and 64-bit Office laptops, when I try to compile my programs, every instance of this command fails:

    lastRow = XLSheet.UsedRange.Rows(XLSheet.UsedRange.Rows.count).Row
    The error message when trying to compile flags the second instance of ".UsedRange" in the above command and is:

    Compile error:
    Method or data member not found

    lastRow is dimensioned as Long
    The Excel objects are dimensioned as follows:

    Dim xlApp As New Excel.Application
    Dim xlBook As Excel.Workbook
    Dim XLSheet As Excel.Worksheet
    In all my applications that use the errored command, this command fails at the same point in each command.

    I have searched the Internet and have not found this issue listed. I realize that .UsedRange is fickle, but it always compiled without a problem. Windows 11 has broken it somehow such that it seems to have been deprecated. I have the proper reference to the Excel Type library in the Word application. Everything worked properly in Windows 10.
    Any ideas why?

  2. #2
    VBAX Regular
    Joined
    Mar 2018
    Location
    Leesburg
    Posts
    71
    Location
    Update: for whatever reason, the fix was to remove the reference to Excel Type Object Library 16.0 debug, and then add the reference back in and lo and behold, it suddenly works!

Tags for this Thread

Posting Permissions

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