---- excel97是microsoft公司出版的电子表格程序,它的处理数据的功能十分强大,但再好的软件都有它的一定的局限性,为了解决excel97的局限性excel97/2000内置了一个宏程序编辑器,以解决更多的人的更多需要。
---- 在日常工作中,我们经常使用到绘图程序,如用cad绘制图形,如果想绘制一个要求精度不是太高的图纸那么cad就有点大材小用了,如果只是作为您的参考:比如股市走向用它看看行情,那么您完全可以使用它———vba for excel97/2000皆可(全称为visual basic for application以后简称vba)。
---- 一个网民曾经问过我:如果:给出x和y轴能不能让excel97的宏程序也划出一个曲线图呢?而不用excel97的图表功能?
---- 为此我考虑使用excel97中的shape对象来编写这个程序,经过我的一天努力终于搞出了一段vba程序,使用起来也十分方便!我想如果您认为可以近一步扩展,您还可以沿着我的思路,近一步深化编写,编写出一个自己满意的小程序!在启动excel97时别忘记“启用宏”,否则无法运行!
---- 点击绘图按钮后,弹出对话框提示输入延伸的行数!(如果输入大于对话框中的值时将只得到曲线图没有数值)
代码如下(把它放到模块中):
这段代码是绘制一个曲线图:
| sub drawing() ' liuzheng welcome you to visit my homepage http://grwy.online.ha.cn/vba_excel97/ range("a1").select selection.currentregion.select myrow = selection.rows.count '计算行数 my = application.inputbox("输入延伸的行数。" & chr(13) & chr(13) & "提示:如果输入" & myrow + 1 & ",将只绘制线条" & chr(13) & chr(13) & "(没有数值!)", "用vba绘图", default:=myrow) '弹出输入对话框 if my = cancel then range("a1").select exit sub end if '条件测试 activesheet.shapes.selectall selection.delete '删除所有的shapes activesheet.buttons.add(245.25, 34.5, 102, 36).select b = selection.name selection.onaction = "del_shapes" activesheet.shapes(b).select selection.characters.text = "删图" with selection.characters(start:=1, length:=3).font .size = 22 .shadow = true end with '做一个删除按钮 with activesheet.shapes.buildfreeform(msoeditingauto, range("a2").value, range("b2").value) for i = 3 to my if range("a" & i).value = "" and range("b" & i).value = "" then .converttoshape.select exit sub end if .addnodes msosegmentcurve, msoeditingauto, range("a" & i).value, range("b" & i).value next i .converttoshape.select end with for i = 2 to my a = range("a" & i).value b = range("b" & i).value activesheet.shapes.addshape(msoshaperectangle, a, b, 48.75, 21).select selection.characters.text = a & "," & b with selection.characters(start:=1, length:=6).font .name = "times new roman" end with selection.horizontalalignment = xlcenter selection.shaperange.fill.visible = msofalse selection.shaperange.fill.transparency = 0# selection.shaperange.line.transparency = 0# selection.shaperange.line.visible = msofalse activesheet.shapes.addshape(msoshapeoval, a, b, 1.5, 1.5).select selection.shaperange.fill.forecolor.schemecolor = 5 next i '以上是用vba绘图 msgbox "欢迎参观我的个人主页 http://grwy.online.ha.cn/vba_excel97/或者 http://202.102.233.10/64215258/", vbinformation, "用vba绘图" range("b1").select end sub '这段代码为:删除图片,并再做一个绘图按钮 sub del_shapes() activesheet.shapes.selectall selection.delete application.screenupdating = false activesheet.buttons.add(245.25, 34.5, 102, 36).select b = selection.name selection.onaction = "drawing" activesheet.shapes(b).select selection.characters.text = "绘图" with selection.characters(start:=1, length:=3).font .size = 22 .shadow = true end with range("b1").select end sub |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器