打开宏录制,自己手动操作一遍设置,然后关闭宏,查看录制的宏的代码。
Public Class Form1
Public WW As New Microsoft.Office.Interop.Word.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WW.Documents.Open(System.IO.Directory.GetCurrentDirectory & "\1.doc")
WW.Visible = True
WW.WindowState = Interop.Word.WdWindowState.wdWindowStateMinimize
WW.WindowState = Interop.Word.WdWindowState.wdWindowStateMaximize
WW.Documents(1).Select()
WW.Documents(System.IO.Directory.GetCurrentDirectory & "\1.doc").Activate()
WW.ActiveDocument.Paragraphs(1).Range.Select() '选中第一段
WW.Selection.ParagraphFormat.LineSpacingRule = Interop.Word.WdLineSpacing.wdLineSpaceDouble '2倍行间距
'Dim hh As String
'hh = WW.ActiveDocument.Range(Start:=59, End:=165).Text
End Sub
End Class