這段時間在搞一些書法的東西。從視頻上直接截圖,粘貼到word裏就會按照頁寬直接設置圖片寬度,但重新排版改變了頁邊距之後就難看了。做了個VBA宏解決問題。
已經很久不搞挨踢了,但還是很以擁有IT技能爲榮,確實比普通人擅長解決問題。目前覺得,離開IT本行也能用得到的IT技能有:Html,正則表達式,Office。當然別忘了還有男人必備技能——裝系統。
Sub 按頁寬調整圖片()
pw = ActiveDocument.PageSetup.PageWidth - ActiveDocument.PageSetup.LeftMargin - ActiveDocument.PageSetup.RightMargin
Dim oInlineShape As InlineShape
For Each oInlineShape In ActiveDocument.InlineShapes
With oInlineShape
.ScaleWidth = 100 '先都設成原始大小
If .Width > pw Then
.Width = pw '然後調整爲頁寬
End If
End With
Next
End Sub