<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Word-通過宏格式化文檔中的表格和圖片

      1、打開Word文檔,找到”視圖“,然后點擊”宏“。

      image

       

      2、創建宏腳本。

      Sub A表格格式化()
          On Error Resume Next
          Application.ScreenUpdating = False
          Dim tbl As Table, cell As cell
          Dim counter As Integer: counter = 1
          Dim response As VbMsgBoxResult
          Dim r As Long, c As Long
          
          ' 遍歷文檔中所有表格
          For Each tbl In ActiveDocument.Tables
              
              ' --- 核心設置 ---
              ' 設置表格寬度
              tbl.PreferredWidthType = wdPreferredWidthPercent      ' 寬度度量單位:百分比
              tbl.PreferredWidth = 98                               ' 百分比
              tbl.AllowAutoFit = False
              
              ' 設置表格所在段落的行距
              tbl.Range.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle
              tbl.Range.ParagraphFormat.SpaceBefore = 0
              tbl.Range.ParagraphFormat.SpaceAfter = 0
              
              ' 設置表格整體對齊
              tbl.Rows.Alignment = wdAlignRowCenter
              
              ' --- 邊框設置(支持合并單元格)---
              With tbl.Borders
                  .Enable = True
                  .OutsideLineStyle = wdLineStyleSingle
                  .OutsideLineWidth = wdLineWidth050pt
                  .InsideLineStyle = wdLineStyleSingle
                  .InsideLineWidth = wdLineWidth050pt
              End With
              
              ' --- 逐個單元格處理(避免合并單元格錯誤)---
              For r = 1 To tbl.Rows.Count
                  For c = 1 To tbl.Columns.Count
                      ' 跳過合并單元格中的重復單元格
                      If tbl.cell(r, c).rowIndex = r And tbl.cell(r, c).ColumnIndex = c Then
                          
                          With tbl.cell(r, c)
                              ' 設置單元格垂直對齊
                              .VerticalAlignment = wdCellAlignVerticalCenter
                              
                              ' 設置段落水平對齊
                              .Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
                              
                              ' 設置字體
                              .Range.Font.Name = "宋體"
                              .Range.Font.NameFarEast = "宋體"
                              .Range.Font.Size = 10.5
                              .Range.Font.Color = RGB(0, 0, 0)
                              
                              ' 設置首行格式
                              If r = 1 Then
                                  .Range.Font.Bold = True
                                  .Shading.BackgroundPatternColor = RGB(242, 242, 242)
                              Else
                                  .Range.Font.Bold = False
                                  .Shading.BackgroundPatternColor = wdColorAutomatic
                              End If
                          End With
                          
                      End If
                  Next c
              Next r
              
              ' --- 設置行高 ---
              ' 單獨處理每行,避免合并單元格影響
              For r = 1 To tbl.Rows.Count
                  On Error Resume Next
                  tbl.Rows(r).Height = CentimetersToPoints(0.8)  ' 調整為0.8厘米,更緊湊
                  tbl.Rows(r).HeightRule = wdRowHeightAtLeast
              Next r
              
              ' --- 每20個表格提示一次 ---
              If counter Mod 20 = 0 Then
                  response = MsgBox("已處理第 " & counter & " 個表格" & vbNewLine & _
                                    "點擊【確定】繼續,【取消】中止", _
                                    vbOKCancel + vbInformation, "批量進度提示")
                  
                  If response = vbCancel Then
                      Application.ScreenUpdating = True
                      MsgBox "操作已中止!共完成 " & (counter - 1) & " 個表格", vbExclamation, "表格樣式設置"
                      Exit For
                  End If
              End If
              counter = counter + 1
              
          Next tbl
          
          ' 收尾處理
          Application.ScreenUpdating = True
          If response <> vbCancel Then
              MsgBox "表格設置已完成!" & vbCrLf & vbCrLf & _
                     "所有表格已設置為頁面寬度、居中對齊" & vbCrLf & _
                     "支持合并單元格的復雜表格" & vbCrLf & vbCrLf & _
                     "共處理 " & (counter - 1) & " 個表格", _
                     vbInformation, "表格樣式設置"
          End If
      End Sub
      
      
      '' 厘米轉磅函數(1厘米=28.35磅)
      Function CentimetersToPoints(ByVal cm As Single) As Single
          CentimetersToPoints = cm * 28.35
      End Function
      
      
      
      Sub B圖片格式化()
          ' 聲明變量
          Dim shp As Shape
          Dim ilshp As InlineShape
          Dim pageWidth As Single
          Dim leftMargin As Single
          Dim rightMargin As Single
          Dim usableWidth As Single
          
          ' 關閉屏幕更新以提高宏運行速度
          Application.ScreenUpdating = False
          
          ' 設置錯誤處理,跳過無法處理的圖片
          On Error Resume Next
          
          ' 計算頁面可用寬度(點數)
          With ActiveDocument.PageSetup
              pageWidth = .pageWidth
              leftMargin = .leftMargin
              rightMargin = .rightMargin
          End With
          
          ' 計算可用寬度 = 頁面寬度 - 左邊距 - 右邊距
          usableWidth = pageWidth - leftMargin - rightMargin
          
          ' 第一部分:處理嵌入型圖片(InlineShapes)
          For Each ilshp In ActiveDocument.InlineShapes
              If ilshp.Type = wdInlineShapePicture Or ilshp.Type = wdInlineShapeLinkedPicture Then
                  ' 設置圖片寬度為頁面可用寬度
                  ilshp.Width = usableWidth
                  ' ★ 新增:取消首行縮進并設置居中對齊
                  With ilshp.Range.ParagraphFormat
                      .CharacterUnitFirstLineIndent = 0    ' 取消字符單位首行縮進
                      .FirstLineIndent = 0                 ' 取消磅單位首行縮進
                      .Alignment = wdAlignParagraphCenter   ' 段落后中包括圖片
                  End With
              End If
          Next ilshp
          
          ' 第二部分:處理浮動型圖片(Shapes)
          For Each shp In ActiveDocument.Shapes
              If shp.Type = msoPicture Or shp.Type = msoLinkedPicture Then
                  ' 鎖定縱橫比,設置寬度為頁面可用寬度
                  shp.LockAspectRatio = msoTrue
                  shp.Width = usableWidth
                  ' ★ 新增:通過錨定段落取消首行縮進并居中對齊
                  If Not shp.Anchor Is Nothing Then
                      With shp.Anchor.ParagraphFormat
                          .CharacterUnitFirstLineIndent = 0
                          .FirstLineIndent = 0
                          .Alignment = wdAlignParagraphCenter
                      End With
                  End If
              End If
          Next shp
          
          ' 完成提示(更新提示文本)
          MsgBox "圖片設置已完成!" & vbCrLf & vbCrLf & _
                 "所有圖片已設置為頁面寬度、居中對齊,并取消首行縮進。", _
                 vbInformation, "圖片樣式設置"
          
          ' 重新開啟屏幕更新
          Application.ScreenUpdating = True
      End Sub

       

      3、運行宏腳本,選中"A表格格式化",點擊”運行“ 按鈕,即可格式化表格。

      image

       執行完成后,彈出對話框。

      image

      4、運行宏腳本,選中"B圖片格式化",點擊”運行“ 按鈕,即可格式化圖片。

      image

        執行完成后,彈出對話框。

      image

       

      posted @ 2025-09-24 11:13  業余磚家  閱讀(72)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 亚洲乱码国产乱码精品精大量 | 国产对白老熟女正在播放| 人妻丝袜AV中文系列先锋影音| 一区二区精品久久蜜精品| 澳门永久av免费网站| 国产中文字幕精品视频| 一道本AV免费不卡播放| 亚洲综合无码明星蕉在线视频| av永久免费网站在线观看| 欧美老熟妇乱子伦牲交视频| 国产专区一线二线三线码| 久久国产成人午夜av影院| 99在线视频免费观看| 欧美大胆老熟妇乱子伦视频| 久久天天躁狠狠躁夜夜躁2o2o| 国产真人性做爰久久网站 | 通海县| 株洲市| 国产偷国产偷亚洲高清人| 一区二区亚洲人妻精品| 国产精品久久久久久av| 久久国产免费观看精品3| 国产欧美精品aaaaaa片| 国产在线精品欧美日韩电影| 国产视频一区二区| 国产精品中文字幕第一区| 亚洲精品中文字幕无码蜜桃 | 欧美性白人极品hd| 91精品蜜臀国产综合久久| 免费a级毛片18以上观看精品| 国产综合久久99久久| 人妻va精品va欧美va| 精品国产成人A区在线观看| 欧美激情一区二区三区成人 | 亚洲女同精品久久女同| 亚洲综合不卡一区二区三区| 国产欧美日韩va另类在线播放| 91热在线精品国产一区| 国产资源精品中文字幕| 久久男人av资源网站| 非会员区试看120秒6次|