这会将Microsoft Word 2013切换到主页选项卡:
Sub HomeTab()
Application.ScreenUpdating = False
SendKeys "%h%"
ScreenUpdating = True
End Sub
这会打开一个文档:
Sub OpenToDoLIst()
Documents.Open FileName:="C:\Users\Name\Name Documents\Microsoft Word Documents\Work Menu\To Do List.doc"
End Sub
但如果我把这两者结合起来:
Sub WorkOpenToDoList()
Application.ScreenUpdating = False
SendKeys "%h%"
ScreenUpdating = True
Documents.Open FileName:="C:\Users\Name\Name Documents\Microsoft Word Documents\Work Menu\To Do List.doc"
End Sub
当我将宏启动到Home选项卡时,它不会切换我开始的原始文档,它只打开文档。我怀疑它没有等待HomeTab步骤在原始窗口中完成,但我不知道为什么。