办公软件2003和2007之间的VBA版本有区别吗?

7

我可以毫无顾虑地使用Access 2007 VBA引用来开发基于VBA的解决方案,以便与Access 2003兼容(特别是在基础语言和旧COM接口方面)吗?

还是说有一些新的/修改过的语法需要我注意?

Office 2007是否极大地增强了对象模型?

还有其他需要注意的地方吗?

3个回答

9

微软办公软件的最近几个版本中,VBA语言本身并没有发生变化(未来也不太可能会变化)。从Access2000版本开始,VBA的版本是VBA6。

然而,办公应用程序的对象模型略有改动。微软通常只通过增加方法和属性来扩展OM。就Access而言,我无法提供详细信息,但您可以在此处找到修改列表:

一般来说,针对某个Office版本开发的VBA解决方案将与更新的版本一起使用。然而,魔鬼在于细节。由于修复漏洞和增加新功能,应用程序可能比旧版本表现略有不同。检查所有功能是否仍然正常工作的唯一方法是进行详尽的测试。


3

Excel 2007中有一些新属性、方法和对象。

然而,大多数Excel 2003程序在Excel 2007中能够正常运行。

但是,有一些来自VBA Excel 2003的东西在Excel 2007中无法使用。

我已经发现了4个问题。

  • "Chart.Add" give automation error in Excel 2007 when there are more than 1 cell selected

  • Error don't reset by itself, it's necessary uses Err.clear before command that could be release a error.

            On Error Resume Next
            Intruction_That_Could_be_buggy_1
            if Err.Number <>0 Then
                 Err.Clear     '  <<<<==== This command is necessary
                 Intruction_That_Could_be_buggy_2                  
                 if Err.Number <>0 Then
                       ....
    
  • Range(...).Paste(xlFormulas) now stops when exists a possible name conflict, it's necessary to use

        Application.displayalerts = False
        Range(....).Paste(xlFormulas)
        Application.displayalerts = True
    
  • Several hotkeys like Alt+N are reserved in Excel 2007. Application.Onkey("%n","rotina") doesn't works in that case. Now it's many ribbon shortcut in the ALT+Letra style. I cannot found any way to suppress this behaviour. It should be used other hotkey instead.


虽然您的回答很好,但我没有看到这个问题与Excel有任何关系。 - David-W-Fenton
你说得对,我有点心不在焉。然而,关于VBA,Excel 2007与Excel 2003相关的问题应该会在其他VBA实现中重复出现。在Word 2007或Outlook 2007中,我还没有发现任何问题(至少目前为止),但我的使用频率较低。 - Paulo Buchsbaum
我并不确定在Word/Excel/Outlook中VBA的限制也适用于Access。 - David-W-Fenton

0

如果你正在将你的accdb/mdb编译成accde/mde,你需要确保它们与你的主应用程序版本相同。我曾经在使用Access 2003 MDE文件与Access 2007(反之亦然)时遇到了一些问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接