论坛数据统计           欢迎到【弱电论坛】来学习和讨论问题!

弱电工程项目管理软件
★电工电气产品供求、电气展会、人才、电气技术文章、图库、电气技术论坛等相关内容,请跳转至【电气工程网】--- 可直接使用本站会员名和密码登陆!(首次使用需要激活账户)
标王 热搜: 网络监控  弱电  楼宇对讲  机房及机柜内部的理线方法  门禁  CAD  ar800-hn  综合布线  工资  面板 
 
 
当前位置: 首页 » 技术 » 电脑技术 » 常用软件 » 正文

批量处理excel批注

放大字体  缩小字体 发布日期:2011-12-09  来源:互联网  作者:manage  浏览次数:1126
核心提示:1.删除批注中的用户名: Private Sub CommandButton1_Click() For Each i In ActiveSheet.Comments‘批注中的每一个 With i Dim MYSTR1 As Integer‘声明整型 Dim MYSTR2 As Integer‘声明整型 Dim RESULT As Integer‘声明整型 MYSTR1 = Len(.Author)‘作者的长

1.      删除批注中的用户名:

Private Sub CommandButton1_Click()

For Each i In ActiveSheet.Comments    批注中的每一个

  With i

  Dim MYSTR1 As Integer   声明整型

  Dim MYSTR2 As Integer   声明整型

  Dim RESULT As Integer   声明整型

  MYSTR1 = Len(.Author)   作者的长度

  MYSTR2 = Len(.Text)      整个批注的长度

  RESULT = MYSTR2 - MYSTR1 – 1   再减1是因为有一个冒号 占一位

.Text Right(.Text, RESULT)  批注的文本为原批注从右边取除了作者名的长度

            .Visible = True    将批注视为可见

  End With  

Next

End Sub

2.      将批注中的用户名更名:

在上述代码后接以下代码:

Private Sub CommandButton1_Click()

For Each i In ActiveSheet.Comments    批注中的每一个

  With i

  Dim MYSTR1 As Integer   声明整型

  Dim MYSTR2 As Integer   声明整型

  Dim RESULT As Integer   声明整型

  MYSTR1 = Len(.Author)   作者的长度

  MYSTR2 = Len(.Text)      整个批注的长度

  RESULT = MYSTR2 - MYSTR1 – 1   再减1是因为有一个冒号 占一位

.Text Right(.Text, RESULT)  批注的文本为原批注从右边取除了作者名的长度

            .Visible = True    将批注视为可见

  End With  

For Each i In ActiveSheet.Comments  遍历每一个批注

     i.Text "PL:" & ONE.Text   批注的文本前加PL:

Next

End Sub

3.      将批注中的用户名更名:

在上述代码后接以下代码:

Private Sub CommandButton1_Click()

Dim mCom As Comment

For Each mCom In ActiveSheet.Comments

     With mCom.Shape.TextFrame.Characters

         With .Font

                 .Bold = msoTrue '改变粗细

                 .Size = 14      '改变大小

                 .ColorIndex = 3 '改变颜色

             End With

         End With

     Next

End Sub

4.       删除所有批注

Private Sub CommandButton1_Click()

            For each i in activesheet.comments

                        i.delete

            next

End sub

5.       导出批注

Private Sub CommandButton1_Click()

On Error GoTo line

Application.DisplayAlerts = False

Application.ScreenUpdating = False

Dim cur, temp As Worksheet

Set cur = ActiveSheet

Set temp = Worksheets.Add

temp.Name = "导出批注"

Dim row As Integer

row = 1

For Each one In cur.Comments

    temp.Cells(row, 1).Value = one.Text

    temp.Cells(row, 2).Value = one.Parent.row

    temp.Cells(row, 3).Value = one.Parent.Column

    one.Delete

    row = row + 1  

Next

    MsgBox "批注导出到表中"

Application.DisplayAlerts = True

Application.ScreenUpdating = True

Exit Sub

line:

MsgBox "批注未导出,可能以前导过."

temp.Delete

Application.DisplayAlerts = True

Application.ScreenUpdating = True

End Sub

 
[ 技术搜索 ]  [ 加入收藏 ]  [ 告诉好友 ]  [ 打印本文 ]  [ 关闭窗口 ]

 
0条 [查看全部]  相关评论

 
点击排行
 
 
 
弱电基础 | 常用软件 | 信息发布规则 | 积分规则 | VIP会员注册 | 广告投放 | 弱电培训 | 联系我们 | 版权声明 | 帮助中心 | 网站地图 | 排名推广 | 京ICP备11008917号-3 | RSS订阅
★本站手机app客户端已上线! 点击下载