|
楼主 |
发表于 2018-9-3 20:52
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
1)ListBox1的宽度、高度在下面代码设置
With Me.ListBox1
......
.Width = Target.Width * 6 '宽度为6倍C列宽度
.Height = Target.Height * 7 '高度为7倍行高
End With
2)打印,要指定设置项:
Private Sub CommandButton4_Click() '打印
'Application.Dialogs(xlDialogPrinterSetup).Show '一句话代码,调出系统对话框手动设置选择打印区域
'----------------------------------------------
With ActiveSheet.PageSetup
.PaperSize = xlPaperA5 '设置纸张的大小为A5纸
.Orientation = xlPortrait '该属性返回或设置页面的方向。wpsOrientPortrait 纵向;wpsOrientLandscape 横向
.LeftMargin = Application.InchesToPoints(0.50955)
.RightMargin = Application.InchesToPoints(0.50955)
.TopMargin = Application.InchesToPoints(0.50955)
.BottomMargin = Application.InchesToPoints(0.50955)
.HeaderMargin = Application.InchesToPoints(0.03937)
.FooterMargin = Application.InchesToPoints(0.03937)
.PrintGridlines = True
.CenterHorizontally = True '页面的水平居中
'.CenterVertically = True '页面垂直居中
.Zoom = False '将页面缩印在一页内
.FitToPagesWide = 1 '自动适应页宽
If Range("A6") <> "" Then
.PrintArea = "" '取消打印区域
'.PrintArea = "$A$1:$J$21"
'Range("A1:J21").PrintOut Copies:=1, Collate:=True '打印指定区域,直接打印
Range("A1:J21").PrintOut Copies:=1, Preview:=True, Collate:=True '打印预览。
End If
'[a1:j21].PrintOut
End With
End Sub
3)生成编码:
Private Function 生成编号() As String
…………
生成编号 = theYear & theMonth & theDay & Format(CVar(theStrMaxNumNow) + 1, "00") '这句就是编码格式,自己随便改
End Function
|
|