Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2227|回复: 5

【求助】大家帮忙看看下面的代码,2010版下盖章失效!

[复制链接]
发表于 2012-7-30 22:28 | 显示全部楼层 |阅读模式
一下代码摘自“【聚宝瓶】自动加盖公章工具”(http://www.excelpx.com/thread-161584-1-1.html),在03版excel下测试成功,刚升级2010版后发现盖出的章变形了(如下图),代码大都一些图形及艺术字的操作,本人刚入门,还请大家帮忙看看!
未命名.jpg
  1. Sub 加盖公章()
  2.     Dim txt1 As String
  3.     Dim txt2 As String
  4.     Dim INSLeft, INSTop As String
  5.     Dim rng As Range

  6.     On Error Resume Next

  7.     txt1 = InputBox("请输入单位名称:", "自动加盖公章", "EP精英培训网")
  8.     txt2 = InputBox("请输入公章附文:", "自动加盖公章", "培训部")

  9.     Application.ScreenUpdating = False

  10.     '删除原来的公章
  11.     ActiveSheet.Shapes("公章").Delete

  12.     Set rng = Selection
  13.     INSLeft = Selection.Left    '获得光标的LEFT位置
  14.     INSTop = Selection.Top    '获得光标的TOP位置

  15.     '插入圆
  16.     ActiveSheet.Shapes.AddShape(msoShapeOval, INSLeft, INSTop, 112#, 112#).Select
  17.     Selection.Name = "圆"
  18.     Selection.ShapeRange.Fill.Visible = msoFalse    '透明
  19.     Selection.ShapeRange.Line.Weight = 3#    '加粗
  20.     Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)    '红色

  21.     '插入单位名称
  22.     ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, txt1, "仿宋_GB2312", 36#, msoFalse, msoFalse, INSLeft + 22, INSTop + 18).Select
  23.     Selection.Name = "单位名"
  24.     Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
  25.     Selection.ShapeRange.Line.Weight = 1.2
  26.     Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)
  27.     Selection.ShapeRange.Height = 67.75
  28.     Selection.ShapeRange.Width = 67.75
  29.     Selection.ShapeRange.TextEffect.Tracking = 1.2
  30.     Selection.ShapeRange.Adjustments.Item(1) = 210

  31.     '插入五角星
  32.     ActiveSheet.Shapes.AddShape(msoShape5pointStar, INSLeft + 38, INSTop + 34, 36#, 36#).Select
  33.     Selection.Name = "五角星"
  34.     Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
  35.     Selection.ShapeRange.Line.Weight = 1.2
  36.     Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)
  37.     Selection.ShapeRange.Height = 35.45
  38.     Selection.ShapeRange.Width = 35.45

  39.     '插入公章名称
  40.     ActiveSheet.Shapes.AddTextEffect(msoTextEffect1, txt2, "仿宋_GB2312", 36#, msoFalse, msoFalse, INSLeft + 26, INSTop + 73).Select
  41.     Selection.Name = "公章名"
  42.     Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 0, 0)
  43.     Selection.ShapeRange.Line.Weight = 1.2
  44.     Selection.ShapeRange.Line.ForeColor.RGB = RGB(255, 0, 0)
  45.     Selection.ShapeRange.Height = 28.35
  46.     Selection.ShapeRange.Width = 62.35

  47.     '组合图片
  48.     ActiveSheet.Shapes.Range(Array("五角星", "单位名", "圆", "公章名")).Select
  49.     Selection.ShapeRange.Group.Select
  50.     Selection.Name = "公章"
  51.     rng.Select
  52.     Set rng = Nothing
  53.     Application.ScreenUpdating = True

  54. End Sub


复制代码
发表于 2012-7-30 22:43 | 显示全部楼层
本帖最后由 Select 于 2012-7-30 23:09 编辑

如果我碰到这种情况就:先从简单图开始,录制宏,明白后再给自己增加难度 ...
10下运行到这句,就走样了

    '所选艺术字中每个字符的水平间隔相对于字符宽度的比例,为稀疏
    Selection.ShapeRange.TextEffect.Tracking = 1.2

等学习吧{:261:}


回复

使用道具 举报

发表于 2012-7-31 06:46 | 显示全部楼层
会不会是有参数所代表的意义有变化了。
回复

使用道具 举报

发表于 2012-7-31 09:43 | 显示全部楼层
对照后发现,下面这句是插入一个艺术字对象(TextEffect),在03和10中效果不同:
ActiveSheet.Shapes.AddTextEffect(msoTextEffect3, txt1, "仿宋_GB2312", 36#, msoFalse, msoFalse, INSLeft + 22, INSTop + 18).Select



03



10


因为还不会把10里的第三个文本效果,改成03里的样子。但至少说明只用AddTextEffect方法,两者有别。
等会技巧了,通过录制宏,也是可学会对应代码的。
回复

使用道具 举报

 楼主| 发表于 2012-7-31 11:01 | 显示全部楼层
Select 发表于 2012-7-31 09:43
对照后发现,下面这句是插入一个艺术字对象(TextEffect),在03和10中效果不同:
ActiveSheet.Shapes.Add ...
  1.      Selection.ShapeRange.TextEffect.PresetShape = msoTextEffectShapeArchUpCurve
  2.     Selection.ShapeRange.TextFrame2.WordArtformat = msoTextEffect1
复制代码
添加以上两句可以设置为跟随路径!你试下!

回复

使用道具 举报

 楼主| 发表于 2012-7-31 11:05 | 显示全部楼层
Select 发表于 2012-7-31 09:43
对照后发现,下面这句是插入一个艺术字对象(TextEffect),在03和10中效果不同:
ActiveSheet.Shapes.Add ...
  1. With Selection.ShapeRange.TextFrame2.TextRange.Font.Line
  2.         .Visible = msoTrue
  3.         .ForeColor.RGB = RGB(255, 0, 0)
  4.         .Transparency = 0
  5.     End With
  6.     With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill
  7.         .Visible = msoTrue
  8.         .ForeColor.RGB = RGB(255, 0, 0)
  9.         .Transparency = 0
  10.         .Solid
  11.     End With
复制代码
文字填充颜色也有不同!一块学吧!

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-30 18:07 , Processed in 1.142938 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表