Word for mac 2016.录制简单的宏会显示错误消息 [英] Word for mac 2016. Recording a simple Macro gives an error message
问题描述
假设我想要一个打印此行的宏:"这是一个测试"单词"is"红色。
Assume I want a macro that will print this line: "This is a test" with the word "is" in red.
所以我点击"记录宏",输入句子,光标到"是",选择它,选择" ;字体"从格式菜单中选择红色。
So I click "record macro", type the sentence, cursor to "is", select it, select "font" from the Format menu and select red.
运行宏时出现错误。
这是生成的代码:
¥b $ b
这是错误:运行 - 时间错误'5941'请求的集合成员不存在。
And here is the error: Run-time error '5941' The requested member of the collection does not exist.
当我点击"debug"时箭头指向这一行: With ActiveDocument.Styles("")。Table.Condition(wdFirstRow).Font
When I hit "debug" the arrow points to this line: With ActiveDocument.Styles("").Table.Condition(wdFirstRow).Font
我从来没有遇到过这种问题在上一版Word中的事情。
I've never had a problem with this sort of thing in the previous edition of Word.
推荐答案
宏尝试更改表格样式,但样式名称为空( "")。这是一个奇怪的错误(样式不能有空名,因此错误信息)。
The macro tries to change a table style, but the name of the style is empty (""). That is a weird error (a style cannot have an empty name, hence the error message).
这应该有效:
Sub killme2()
Selection.TypeText Text:=" This is a test。"
$
Selection.MoveLeft单位:= wdCharacter,计数:= 8
Selection.MoveLeft单位:= wdCharacter,Count:= 2,Extend:= wdExtend
Selection.Font.ColorIndex = wdRed
End Sub
Sub killme2()
Selection.TypeText Text:="This is a test."
Selection.MoveLeft Unit:=wdCharacter, Count:=8
Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.Font.ColorIndex = wdRed
End Sub
这篇关于Word for mac 2016.录制简单的宏会显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!