|
- Private Sub UserForm_Activate()
- Dim Arr1, Arr2, Arr3
- Arr1 = Array("A4", "A3")
- Arr2 = Array("竖向", "横向")
- Arr3 = Array("第&P页 总&N页", "&D")
- Me.ComboBox1.List = Arr1: Me.ComboBox2.List = Arr2
- Me.ComboBox3.List = Arr3: Me.ComboBox4.List = Arr3
- Me.ComboBox5.List = Arr3: Me.ComboBox6.List = Arr3
- Me.ComboBox7.List = Arr3: Me.ComboBox8.List = Arr3
- Me.ComboBox1.Value = "A4"
- Me.ComboBox2.Value = "竖向"
- Me.ComboBox7.Value = "第&P页 总&N页"
- Me.TextBox3.Value = "1.0": Me.TextBox6.Value = "0.8"
- Me.TextBox4.Value = "1.2": Me.TextBox7.Value = "1.2"
- Me.TextBox5.Value = "0.8": Me.TextBox8.Value = "0.8"
- End Sub
- Private Sub CommandButton1_Click()
- Dim Rng As Range
- On Error Resume Next
- Set Rng = Application.InputBox("请选择打印区域", "指定打印区域", , , , , , 8)
- If err <> 0 Then
- Me.TextBox1.Value = ""
- err.Clear
- Else
- Me.TextBox1.Value = Rng.Address
- End If
- End Sub
- Private Sub CommandButton2_Click()
- Dim Rng As Range
- On Error Resume Next
- Star:
- Set Rng = Application.InputBox("请选择用于顶端标题的行,例如$1:$1或者$1:$2或者$1:$3等等", "指定顶端标题", "1:2", , , , , 8)
- If err <> 0 Then
- Me.TextBox2.Value = ""
- err.Clear
- Else
- If Rng.Row <> 1 Then MsgBox "顶端标题须从第一行开始。", 64, "提示": err.Clear: GoTo Star
- If Rng.Rows.Count > 10 Then MsgBox "顶端标题不要大于10行。", 64, "提示": GoTo Star
- Me.TextBox2.Value = Rng.EntireRow.Address
- End If
- End Sub
- Private Sub CommandButton3_Click()
- Application.ScreenUpdating = False
- With ActiveSheet.PageSetup
- .PrintArea = TextBox1.Value
- .PrintTitleRows = TextBox2.Value
- If Me.ComboBox1.Value = "A4" Then
- .PaperSize = xlPaperA4
- Else
- .PaperSize = xlPaperA3
- End If
- If Me.ComboBox2.Value = "横向" Then
- .Orientation = xlLandscape
- Else
- .Orientation = xlPortrait
- End If
- .LeftMargin = TextBox3.Value * 28.6
- .RightMargin = TextBox6.Value * 28.6
- .TopMargin = TextBox4.Value * 28.6
- .BottomMargin = TextBox7.Value * 28.6
- .HeaderMargin = TextBox5.Value * 28.6
- .FooterMargin = TextBox8.Value * 28.6
- .LeftHeader = ComboBox3.Value
- .CenterHeader = ComboBox4.Value
- .RightHeader = ComboBox5.Value
- .LeftFooter = ComboBox6.Value
- .CenterFooter = ComboBox7.Value
- .RightFooter = ComboBox8.Value
- End With
- Unload 打印窗体
- Application.ScreenUpdating = True
- End Sub
- Private Sub CommandButton4_Click()
- End
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|