用Excel中的宏获取VBA中的代码。
来源:互联网 发布:linux ftp命令大全 编辑:程序博客网 时间:2024/05/20 08:28
新建宏,ALT+F11,查看宏的原代码。
已单元格合并,自动换行,自动行高为例子:
工具 -> 宏 - > 录制新宏
操作Excel,设置表格属性,单元格合并,自动换行,最合适行高
停止宏录制
ALT + F11
VBAProject(Book1) -> 模块 -> 模块1
代码如下:
Sub Macro2()
'
' Macro2 Macro
' 宏由 abc 录制,时间: 2007-12-3
'
Columns("A:A").Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True //自动换行
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True //合并单元格
End With
Selection.Rows.AutoFit //自适应行高
End Sub
在Delphi中的代码:
procedure MergeCells(AFirstRow, AFirstCol,
ALastRow, ALastCol: Integer; ASheet: OleVariant);
var
VFirstCell, VLastCell: OleVariant;
begin
VFirstCell := ASheet.Cells[AFirstRow, AFirstCol];
VLastCell := ASheet.Cells[ALastRow, ALastCol];
ASheet.Range[VFirstCell, VLastCell].Select;
ASheet.Application.Selection.WrapText := True;
ASheet.Application.Selection.Orientation := 0;
ASheet.Application.Selection.AddIndent := False;
ASheet.Application.Selection.ShrinkToFit := False;
ASheet.Application.Selection.MergeCells := True;
ASheet.Application.Selection.Rows.AutoFit;
end;
- 用Excel中的宏获取VBA中的代码。
- Excel与VBA编程中的常用代码
- Excel与VBA编程中的常用代码
- Excel与VBA编程中的常用代码
- Excel与VBA编程中的常用代码
- Excel中的VBA编程
- EXCEL VBA中的类
- Excel中的VBA编程
- c#调用excel中的vba宏
- 用vba删除Excel中的超连接
- VBA中的一些代码
- 用VBA获取文件夹中的文件列表
- VBA删除EXCEL中的Names
- Excel 2010 中的 VBA 入门
- Excel中的vba基础入门
- WPS EXCEL中的VBA编程
- Excel 2010 中的 VBA 入门
- 用VBA宏代码破解Excel密码保护
- 五句话足以改变人生
- errno 错误对照表
- 面向对象设计的经验原则
- ASP中几种打开记录集方式的比较
- 由于激活没有在指定的时间内完成,COM+ 激活没有成功的解决方案!
- 用Excel中的宏获取VBA中的代码。
- 使用ajax技术无刷新动态调用股票信息(改良版)
- netbeans下实现ajax的传值(get传值)
- 终于进步了!
- netbeans下实现ajax的传值(post传值)
- 15位与18位身份证转换程序片段
- 手机软件开发环境介绍
- 电子现金系统技术
- 三层开发顺序