word vba:循环文件重置格式
我想循环浏览我的word文档,删除每个单词上的所有背景色。这是到目前为止我的代码,但它不起作用-我收到以下错误消息“Argument not optional”,并突出显示“.Item”:word vba:循环文件重置格式,vba,ms-word,format,Vba,Ms Word,Format,我想循环浏览我的word文档,删除每个单词上的所有背景色。这是到目前为止我的代码,但它不起作用-我收到以下错误消息“Argument not optional”,并突出显示“.Item”: Sub ResetColor() Dim doc As Document Set doc = ActiveDocument Set eword = doc.Range.Words.Item For i = 1 To doc.Range.Words eword.Shading.Texture = wd
Sub ResetColor()
Dim doc As Document
Set doc = ActiveDocument
Set eword = doc.Range.Words.Item
For i = 1 To doc.Range.Words
eword.Shading.Texture = wdTextureNone
eword.Shading.ForegroundPatternColor = wdColorAutomatic
eword.Shading.BackgroundPatternColor = wdColorAutomatic
Next
End Sub
试试这个:
Sub ResetColor()
Dim doc As Document
Set doc = ActiveDocument
For Each eword In doc.Range.Words
eword.Shading.Texture = wdTextureNone
eword.Shading.ForegroundPatternColor = wdColorAutomatic
eword.Shading.BackgroundPatternColor = wdColorAutomatic
Next
End Sub
我收到一条错误消息“Command not available”(命令不可用),虽然宏正确启动,但eword.Shading.Texture=WDTextureOne会高亮显示。如果文档受保护或为只读,则会发生此错误。确保您对文档具有写访问权限。嗯。否该文档不受保护且不是只读的。两者都选中,但它在新文档上工作,因此宏可以工作。谢谢。