国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

WordVBA-批量整頁插入非嵌入式圖片-分析和解決問題全流程

2023-04-15 11:17 作者:ch_j  | 我要投稿

rem 本視頻代碼(路徑在您的電腦上,需要根據(jù)自己的實(shí)際情況改一下):


Sub 形狀插入()

Dim sp As Shape


Set sp = ActiveDocument.Shapes.AddPicture("E:\資料\學(xué)習(xí)\答疑\VBA\20230414批量插入圖片\圖片\01.jpg", Anchor:=ActiveDocument.Paragraphs.Last.Range)


With sp

.WrapFormat.Type = wdWrapBehind

.LockAspectRatio = True

If .Width / .Height >= .Anchor.Sections.First.PageSetup.PageWidth / .Anchor.Sections.First.PageSetup.PageHeight Then

'圖片寬高比大于等于圖片所在的頁面寬高比時(shí):

.Height = .Anchor.Sections.First.PageSetup.PageHeight

Else

.Width = .Anchor.Sections.First.PageSetup.PageWidth

End If


'設(shè)置水平和垂直對齊方式:相對于頁面居中

.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage

.Left = WdShapePosition.wdShapeCenter


.RelativeVerticalPosition = wdRelativeVerticalPositionPage

.Top = wdShapeCenter

End With

End Sub



'***在Word VBA中:形狀不能轉(zhuǎn)圖片,圖片可以轉(zhuǎn)形狀

Sub 圖片插入()

Dim isp1 As InlineShape

Set isp1 = ActiveDocument.InlineShapes.AddPicture("E:\資料\學(xué)習(xí)\答疑\VBA\20230414批量插入圖片\圖片\01.jpg", Range:=Selection.Range)


Dim sp As Shape

Set sp = isp1.ConvertToShape


With sp

.WrapFormat.Type = wdWrapBehind

.LockAspectRatio = True

If .Width / .Height >= .Anchor.Sections.First.PageSetup.PageWidth / .Anchor.Sections.First.PageSetup.PageHeight Then

'圖片寬高比大于等于圖片所在的頁面寬高比時(shí):

.Height = .Anchor.Sections.First.PageSetup.PageHeight

Else

.Width = .Anchor.Sections.First.PageSetup.PageWidth

End If


'設(shè)置水平和垂直對齊方式:相對于頁面居中

.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage

.Left = WdShapePosition.wdShapeCenter


.RelativeVerticalPosition = wdRelativeVerticalPositionPage

.Top = wdShapeCenter

End With

End Sub


Sub 批量插入圖片()

Dim fd As FileDialog

Dim s As String

Dim f As String

Set fd = Application.FileDialog(msoFileDialogFolderPicker)

With fd

.InitialFileName = ActiveDocument.Path

If .Show Then

s = Dir(.SelectedItems(1) & "\", vbNormal)

Do While s <> ""

f = .SelectedItems(1) & "\" & s

f = LCase(f)

Debug.Print f


'如果限定處理.jpg和.png文件

Dim s1 As String

s1 = Split(f, ".")(UBound(Split(f, ".")))

If s1 = "jpg" Or s1 = "png" Then

Dim sp As Shape


Set sp = ActiveDocument.Shapes.AddPicture(f, Anchor:=ActiveDocument.Paragraphs.Last.Range)


With sp

.WrapFormat.Type = wdWrapBehind

.LockAspectRatio = True

If .Width / .Height >= .Anchor.Sections.First.PageSetup.PageWidth / .Anchor.Sections.First.PageSetup.PageHeight Then

'圖片寬高比大于等于圖片所在的頁面寬高比時(shí):

.Height = .Anchor.Sections.First.PageSetup.PageHeight

Else

.Width = .Anchor.Sections.First.PageSetup.PageWidth

End If


'設(shè)置水平和垂直對齊方式:相對于頁面居中

.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage

.Left = WdShapePosition.wdShapeCenter


.RelativeVerticalPosition = wdRelativeVerticalPositionPage

.Top = wdShapeCenter

End With


ActiveDocument.Range.InsertParagraphAfter

ActiveDocument.Range.Paragraphs.Last.Range.InsertBreak WdBreakType.wdPageBreak

End If


s = Dir

Loop

End If

End With

End Sub

WordVBA-批量整頁插入非嵌入式圖片-分析和解決問題全流程的評論 (共 條)

分享到微博請遵守國家法律
霍州市| 牟定县| 金昌市| 历史| 黑山县| 南漳县| 岑溪市| 海丰县| 安新县| 万州区| 石棉县| 贡嘎县| 广河县| 久治县| 玛纳斯县| 固镇县| 柳江县| 梁平县| 社会| 城固县| 海晏县| 拉孜县| 华宁县| 江北区| 西安市| 错那县| 大埔区| 红河县| 株洲县| 通州市| 辰溪县| 黎城县| 日土县| 博兴县| 五寨县| 水富县| 云阳县| 南召县| 保德县| 富蕴县| 武陟县|