word中寫宏並設置快捷鍵的方法
寫入你要建立的宏名字,然後點“創建”
別刪除已有代碼,在你新創建的sub裏箭頭位置寫內容
添加到快速訪問:文件-》選項-》快速訪問工具欄,在下拉菜單中選擇宏,選擇你剛建的宏,添加到右側。
然後在快速訪問欄上就出現一個按鈕,點這個按鈕就會執行對應的宏。
下面是具體可用的宏。
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1、修改word中所有圖片的寬度自適應頁面寬度(如果圖片寬度小於word頁面寬度,以圖片寬度爲準)
Sub 圖片自適應() ' ' 圖片自適應 宏 ' pw = ActiveDocument.PageSetup.PageWidth - ActiveDocument.PageSetup.LeftMargin - ActiveDocument.PageSetup.RightMargin Dim oInlineShape As InlineShape For Each oInlineShape In ActiveDocument.InlineShapes '遍歷所有嵌入型圖片 With oInlineShape .LockAspectRatio = msoTrue '鎖定寬高比 .ScaleWidth = 100 '先都設成原始大小 If .Width > pw Then .Width = pw '如果圖片大小大於頁面寬度,調整爲頁寬 End If '.Range.Select.Selection.ClearFormatting '清除圖片格式,如縮進等 '.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter '圖片居中 .Range.Style = "圖片格式" '給圖片應用 圖片格式 這個自定義樣式 End With Next End Sub
2、word所有圖
待續。。。。