1.变量声明
Dim a, b, c
2.if语句
If a <> "" Then
Else
End If
3.循环
Do
If b > 0 Then
Else
Exit Do
End If
Loop
4.函数体
Sub space()
End Sub
完整程序
Attribute VB_Name = "NewMacros"
Sub space()
'
' Macro3 Macro
' 宏在 2015-5-4 由 baifan 录制
'
Dim a, b, c
a = InputBox("输入要加入的空格数", "添加空格", "100")
If a <> "" Then
b = CInt(a)
d = b
Do
If b > 0 Then
Selection.TypeText Text:=" "
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
With Selection.Font
.Spacing = -1000
End With
Selection.MoveRight Unit:=wdCharacter, Count:=2
Else
Exit Do
End If
b = b - 1
Loop
Else
MsgBox (" 无参数输入!")
End If
End Sub