|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub test()
Dim Items1 As FileDialogSelectedItems, Items2 As FileDialogSelectedItems
Dim strPath$, i&, Pic As Shape
With Application.FileDialog(1)
With .Filters
.Clear
.Add "PIC Files", "*.png,*.jpg,*.gif"
End With
.Title = "请选择一个图片文件"
.AllowMultiSelect = False
.InitialFileName = strPath
If .Show Then Set Items1 = .SelectedItems Else Exit Sub
End With
With Application.FileDialog(1)
With .Filters
.Clear
.Add "PIC Files", "*.doc*"
End With
.Title = "请选择需导入的文件"
.AllowMultiSelect = True
.InitialFileName = strPath
If .Show Then Set Items2 = .SelectedItems Else Exit Sub
End With
For i = 1 To Items2.Count
If Items2(i) <> ThisDocument.FullName Then
With Documents.Open(Items2(i))
For Each Pic In .Shapes
If Pic.Type = 13 Then Pic.Delete
Next
With .Content.Find
.Text = "请贵司"
.Forward = True
.Execute
If .Found = True Then
.Parent.Select
With Selection
.EndKey unit:=wdLine
.MoveDown unit:=wdLine
With .InlineShapes.AddPicture(Items1(1), , True)
.Select
.LockAspectRatio = True
.Width = 4.5 * 96 / 2.54
Selection.ShapeRange.WrapFormat.Type = 5
End With
End With
End If
End With
.Close True
End With
End If
Next i
End Sub
|
评分
-
3
查看全部评分
-
|