zoukankan      html  css  js  c++  java
  • vba查找word中图和表的题注,设置格式,

    '======================函数1======================
    Sub UpdateFiledStyle() '更新某个域所在行的格式,用于更新表或者图的标题极度有用
    Dim aFeild As Fields
    Dim str As String
    
    For Each aField In ActiveDocument.Fields
    
    str = aField.Code.Text '直接取字符串,他的前后有个看不到的字符串,必须去掉才能比较
    str = Left(str, Len(str) - 1)
    str = Right(str, Len(str) - 1)
    
    If (str = "SEQ 图 * ARABIC") Then
    'MsgBox ("找到域")
    '找到域的位置后,相当于光标定位到行,按End键,光标到最后,在Ctrl+Home,全选此行,再更改样式
    aField.Select
    Selection.EndKey Unit:=wdLine
    Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
    Selection.Style = ActiveDocument.Styles("图标题")
    
    
    End If
    
     
    
    Next aField
    
    End Sub
    
    '======================函数3======================
    Sub UpdateFiledStyleLine() '去掉标题和域数字之间的空格
    Dim aFeild As Fields
    Dim str As String
    'Dim str2 As String
    Dim i As Integer
    i = 1
    For Each aField In ActiveDocument.Fields '.Item(0).
    
    str = aField.Code.Text '直接取字符串,他的前后有个看不到的字符串,必须去掉才能比较
    str = Left(str, Len(str) - 1)
    str = Right(str, Len(str) - 1)
    
    If (str = "SEQ 图 * ARABIC") Then
    'MsgBox ("找到域")
    '选中域所在行,到首行,光标左移,选中前面所有文本,去掉空格
    aField.Select 
    Selection.MoveLeft Unit:=wdCharacter, Count:=1 
    Selection.HomeKey Unit:=wdLine, Extend:=wdExtend 
    Dim strHead As String
    strHead = Selection.Text
    Selection.Text = Replace(strHead, " ", "")
    End If
    
     
    
    Next aField
    
    End Sub
    '======================函数4======================
    Sub UpdateFiledStyleLine2() '去掉域数字和表名之间的多余空格
    'Call UpdateFiledStyleLine
    Dim aFeild As Fields
    Dim str As String
    For Each aField In ActiveDocument.Fields '.Item(0).
    
    str = aField.Code.Text '直接取字符串,他的前后有个看不到的字符串,必须去掉才能比较
    str = Left(str, Len(str) - 1)
    str = Right(str, Len(str) - 1)
    
    If (str = "SEQ 图 * ARABIC") Then
    'MsgBox ("找到域")
    '找到域的位置后,选中域,右移一个字符,将后面的全选,然后去掉所有空格,再在前面加一个空格
    aField.Select
    
    Dim strTail As String
    Selection.MoveRight Unit:=wdCharacter, Count:=1
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend '选中域后面所有文本
    Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    strTail = Selection.Text
    Selection.Text = " " & Replace(strTail, " ", "")
    
    End If
    
    Next aField
    
    End Sub
    
     
    

      

  • 相关阅读:
    oracle 体系结构 基本表空间介绍
    在用tiles框架的时候现了这样的错误
    java test 1
    SQL 日期函数小总结
    JavaEE 多层模型
    用 java 将文件的编码从GBK 转换成 UTF8收藏
    详解Java日期格式化及其使用例子
    java md5编码
    Tiles框架使用总结
    字符串分组求和收藏
  • 原文地址:https://www.cnblogs.com/birds-zhu/p/11363478.html
Copyright © 2011-2022 走看看