2013-10-15 44 views
0

我想用我自己的方式覆盖Word 2010标准快速样式。但是,我得到一个错误如下图所示:VBA语法错误

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

请突出显示您的代码中发生消息的地方ex “~~~”这里是一个错误“.ParagraphFormat.LineSpacing = 12 –

+0

tempDoc是错误的,我写了ActiveDocument,而在VBA代码结束时,我删除了这一行”tempDoc.Close SaveChanges:= wdSaveChanges“,然后每一个工作精细 – user2881446

回答

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