zdqwy19 发表于 2012-3-20 22:45:32

Lisp实现在EXCEL中自动填充

本帖最后由 zdqwy19 于 2012-3-21 09:02 编辑

          用Lisp如何编写在excel选择一行某几个单元格的数据形式实现下拉填充的效果。
          I don't know the reason why you use"AutoFill"method or what the series you want to fill. You must give the default series defined by yourself if you want to use"AutoFill"method. I would like to suggest you to read the help topic about"AutoFill"method. I copied it and pasted it below. Please read it.
Excel Developer Reference
Range.AutoFill Method
Performs an autofill on the cells in the specified range.
Syntax
expression.AutoFill(Destination, Type)
expressionA variable that represents a Range object.
Parameters
Name Required/Optional Data Type Description
Destination Required Range The cells to be filled. The destination must include the source range.
Type Optional XlAutoFillType Specifies the fill type.
Return Value
Variant
Example

This example performs an autofill on cells A1:A20 on Sheet1, based on the source range A1:A2 on Sheet1. Before running this example, type 1 in cell A1 and type 2 in cell A2.
Visual Basic for Applications
Set sourceRange = Worksheets("Sheet1").Range("A1:A2")
Set fillRange = Worksheets("Sheet1").Range("A1:A20")
sourceRange.AutoFill Destination:=fillRange
      这是vba的自动填充说明,我用vlisp改了不成功,有哪位高手愿意帮忙修改一下用vlisp怎么写,谢谢!

snddd2000 发表于 2012-3-21 10:28:54

本帖最后由 snddd2000 于 2012-3-21 10:31 编辑

(vl-load-com)
(setq excelapp0 (vlax-get-object "Excel.Application"))
;;excel程序对象,Application 对象
(setq activeworkbook0 (vlax-get-property excelapp0 'ActiveWorkbook))
;;excel工作簿对象
(setq activesheet0 (vlax-get-property activeworkbook0 'ActiveSheet))
;;excel工作表对象
(setq cells0 (vlax-get-property activesheet0 'cells))
;;excel单元格对象
(setq SourceRange (vlax-get-property cells0 'range "A1:A2"))
(setq FillRange (vlax-get-property cells0 'range "A1:A20"))
(vlax-invoke-method SourceRange 'autofill FillRange 2);;;2007版excel

zdqwy19 发表于 2012-3-21 11:37:33

snddd2000 发表于 2012-3-21 10:28 static/image/common/back.gif


       谢谢!看样子方法是正确的,不出现恼人的错误提示,就是我的电脑cpu一下子就跑了100.或许是我引用时错了,我在查查。

zdqwy19 发表于 2012-3-21 12:45:44

解决了,是电脑测试时错误累加的结果,再次表示感谢。

fdb2007 发表于 2012-4-16 16:15:38

学习,看高手的成果

jyzas 发表于 2013-8-15 07:20:56

谢谢沙发的源码

YDPLDL 发表于 2015-6-6 10:30:00

谢谢沙发的源码!

dbqtju 发表于 2015-6-13 12:35:52

终于看到获得活动工作簿的代码了:(setq activeworkbook0 (vlax-get-property excelapp0 'ActiveWorkbook))。原来如此。谢谢。

itoboy 发表于 2016-7-23 10:59:36

值得学习学习
页: [1]
查看完整版本: Lisp实现在EXCEL中自动填充