最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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-批量整頁插入非嵌入式圖片-分析和解決問題全流程的評論 (共 條)

分享到微博請遵守國家法律
连平县| 五华县| 平度市| 潍坊市| 泰州市| 万全县| 安平县| 渭南市| 鹤峰县| 榆树市| 云龙县| 潜山县| 广河县| 屯昌县| 正镶白旗| 赤城县| 弥渡县| 桃园市| 靖西县| 乌兰浩特市| 合作市| 南投县| 望城县| 年辖:市辖区| 绩溪县| 马关县| 古交市| 尉氏县| 达孜县| 新绛县| 宝鸡市| 景东| 泉州市| 长宁县| 杂多县| 高碑店市| 斗六市| 甘南县| 汝城县| 中江县| 德保县|