Microsoft Office Tutorials and References
In Depth Information
Changing the Borders
' * * * * *¶
Sub InsertPictureWithCaption()¶
'Variable declaration¶
Dim FileToInsert As String¶
Dim rng As Word.Range¶
Dim frm As Word.Frame¶
FileToInsert = GetFileName¶
'The user cancelled¶
If Len(FileToInsert) = 0 Then Exit Sub¶
Set rng = Selection.Range.Paragraphs(1).Range¶
'When in a paragraph with text¶
'move to the top, so that the frame¶
'will be associated with this paragraph¶
'and insert an empty paragraph¶
If Len(rng.Paragraphs(1).Range.Text) <> 1 Then¶
rng.Collapse wdCollapseStart¶
rng.Text = vbCr¶
End If¶
'Put a frame around the paragraph¶
Set frm = rng.Frames.Add(rng)¶
'format the frame¶
FormatFrame frm¶
'Insert a picture into it¶
rng.InlineShapes.AddPicture _¶
FileName:=FileToInsert, _¶
LinkToFile:=LinkGraphic, _¶
SaveWithDocument:=SaveInDoc, _¶
If frm Is Nothing Then¶
AddaCaptionInaFrame rng¶
AddaCaptionInaFrame frm.Range¶
End If¶
'Moves insertion point out of frame¶
Selection.MoveRight Unit:=wdCharacter, Count:=1¶
End Sub¶
' * * * * *¶
Function GetFileName() As String¶
'Variable declaration¶
Dim dlg As Word.Dialog¶
Set dlg = Dialogs(wdDialogInsertPicture)¶
With dlg¶
End With¶
GetFileName = dlg.Name¶
End Function¶
Search JabSto ::

Custom Search