VBA语法错误

时间:2013-10-15 07:02:54

标签: vba syntax ms-word word-vba word-2010

我想用自己的方式覆盖Word 2010标准快速样式。但是我收到了如下所示的错误:

With tempDoc.Styles(wdStyleNormal) '// <-- here is the error
        .Font.Name = "Arial"
        .Font.Size = 10
        .ParagraphFormat.Alignment = wdAlignParagraphJustify
        .ParagraphFormat.LineSpacing = 12
End With

您可以在此处找到完整的代码:http://qranberry.com/stackoverflow/code.bas

1 个答案:

答案 0 :(得分:0)

您需要设置如下所示的文档 ..代码已在我的系统中测试并正常工作

Sub test()
Dim tempDoc As Document 
Set tempDoc = ActiveDocument
With tempDoc.Styles(wdStyleNormal) ' or u can use activedocument instead of tempdoc 
        .Font.Name = "Arial"
        .Font.Size = 30
        .ParagraphFormat.Alignment = wdAlignParagraphJustify
        .ParagraphFormat.LineSpacing = 12
End With
End Sub