Slo*_*ner 3 vba ms-word word-vba
自Word 2010以来MS向MS Word引入的一项新功能是LayoutColumns FootnoteOptions.
因此,下面的代码行在Word 2016中编译: ActiveDocument.Range.FootnoteOptions.LayoutColumns但不在Word 2010中(我没有在Word 2013中测试过).
条件编译器语句似乎没有帮助......除了包含Word 2010的VBA7之外,应用程序版本没有任何内容.
https://msdn.microsoft.com/VBA/Language-Reference-VBA/articles/compiler-constants
所以这不会在Word 2010中编译:
Sub testWd10()
#If Win64 And VBA7 Then
ActiveDocument.Range.FootnoteOptions.LayoutColumns
#End If
End Sub
Run Code Online (Sandbox Code Playgroud)
编译器指令对你没有帮助.您需要确定版本,并对不在旧版Word中的成员调用使用后期绑定.
Sub testWd10()
If Application.Version > 15 Then 'e.g. 15 is Word 2013, change as necessary
Dim myRange As Object 'As Range
Set myRange = ActiveDocument.Range
myRange.FootnoteOptions.LayoutColumns 'Late-bound call
End If
End Sub
Run Code Online (Sandbox Code Playgroud)