-
Notifications
You must be signed in to change notification settings - Fork 0
/
Macro.txt
53 lines (34 loc) · 1.05 KB
/
Macro.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Sub InsertImages()
Dim doc As Word.Document
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Set doc = ActiveDocument
Dim vrtSelectedItem As Variant
Dim theText() As String
Dim theText2 As String
Dim startPosition
Dim endPosition
With fd
.Filters.Add "All Files", "*.*", 1
.FilterIndex = 1
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
Set mg2 = ActiveDocument.Range(0)
mg2.Collapse wdCollapseEnd
doc.InlineShapes.AddOLEObject _
FileName:=vrtSelectedItem, _
LinkToFile:=True, DisplayAsIcon:=True, Range:=mg2, IconFileName:= _
"C:\Program Files\Google\Picasa3\PicasaPhotoViewer.exe", IconIndex:=-19
Set mg1 = ActiveDocument.Range
mg1.Collapse wdCollapseEnd
mg1.MoveEnd Unit:=wdCharacter, Count:=0
theText() = Split(vrtSelectedItem, "\")
theText2 = theText(UBound(theText))
theText2 = Left(theText2, InStrRev(theText2, ".") - 1)
mg1.Text = Chr(13) + Chr(10) + theText2 + Chr(13) + Chr(10) + Chr(13) + Chr(10)
Next vrtSelectedItem
Else
End If
End With
Set fd = Nothing
End Sub