Office 2016 -> 2013 “compile error, can't find project or library”

前端 未结 2 1986
时光说笑
时光说笑 2020-12-06 13:36

I just upgraded to Office 2016, which most of my users haven\'t done, and I\'m getting a new error when users try to run my scripts.

\"Compile Error

相关标签:
2条回答
  • 2020-12-06 13:58

    Office documents where the VBA project references Office apps will work on later Office versions too. When you open them on the later version, they will appear to reference that later version.

    However if you save such file with a later Office version and then open it with the original Office version, you will have MISSING: references to any Office apps other that the one to which the file belongs.
    That is, if you have an Excel file that references Excel and Word, resave it under Office 2016 and then open in Office 2013, the reference to Excel will be fine, but the reference to Word will be MISSING:.

    To avoid this, either always save the file under the earliest Office version that you support, or completely remove the references to other Office apps and use late binding to call them.

    0 讨论(0)
  • 2020-12-06 14:06

    You need to include the Excel 15.0 Object Library in order to use Excel.Range("A2") like that or use late binding as shown below:

      Dim excelApp As object, r as object
      Set excelApp = CreateObject("Excel.Application")
      Set r = excelApp.Range("A2")
    
    0 讨论(0)
提交回复
热议问题